For as long as programming languages have existed, people have fought over which one of them is the fastest. These debates have ranged from serious scientific research to many a heated late night bar discussion. Rather than getting into this argument, let's look at the problem at a higher level, namely how would you compare the performance of two different programming languages. The only really meaningful approach is to do it empirically, that is, implementing a bunch of test programs in both programming languages, benchmarking them and then declaring the winner.
This is hard. Really hard. Insanely hard in some cases and very laborious in any case. Even though the problem seems straightforward, there are a ton of error sources that can trip up the unaware (and even many very-much-aware) performance tester.
- The C++ version is suboptimally coded.
- The testing methodology has a noticeable flaw.
- The compiler used has a major performance regression for C++ as opposed to C.
The difficulty of measurement
- Handle outliers by dropping the points at extreme ends (that is, the slowest and fastest measurements)
- Calculate the mean and/or median for the remaining data points
- Compare the result between different programs, the one with the fastest time wins