I've driven the high-performance Tesla Model S and Model 3, and I've also sampled the BMW M5 and M3.

For me, the BMW M5 beats the Tesla Model S P90D and P100D.

But the Tesla Model 3 Performance upsets the mighty BMW M3.

Right up front, I'll admit that comparing legendary gas-powered performance sedans with Tesla's four-doors could be construed as bogus. Gas versus electric? C'mon, what are you thinking?

But bear with me. The thing is that when I drive a performance car — powered by dinosaur goo, electrons, or anything else — I'm thinking less about the fuel and more about what the vehicle can deliver when the rubber hits road or race track.

Read more: I drove a $119,000 Audi A8 L to see if the ultraluxurious sedan is worth the price. Here's the verdict.

That's my basis for this double comparison: Tesla Model S versus BMW M5, and Tesla Model 3 versus BMW M3. A performance-car head-to-head, looking at the two most critical go-fast sedan segments, midsize and compact.

And another thing: As long-range, high-performance electric vehicles go from not existing to hitting the market in real numbers, buyers are going to be cross-shopping gas with electric.

Read more: We drove an $87,000 Jaguar I-PACE to see how it compares with a $57,500 Tesla Model 3 and a $150,000 Model X. Here's the verdict.

My idea here is to ignore many of the peculiarities of electric cars and the environmental issues of low-mpg gas cars and make this a fair fight, all about the driving part.

So how do the cars of the future match up against the Ultimate Driving Machines? Read on to find out.