C++ performance myths debunked

Gerson Kurz gerson.kurz at t-online.de
Sat Aug 3 05:59:44 CEST 2002


On Sat, 03 Aug 2002 01:16:13 GMT, "Neil Hodgson"
<nhodgson at bigpond.net.au> wrote:

>
>   1250 ms with Python 2.2. 1170 ms with -O. Nowhere near as good as you
>see.

I tried that again. I compiled the C++ binary with /O2 (VC6 has no /GL
option) and do not start it in the debugger, but just in the shell
(this was a mistake in my previous test). I consistently (10 attempts,
averaged out) now get these numbers:

boost - 501 ms
ptools - 203 ms
strtok - 62 ms

vs 

python - 453 ms
"python -o" - 420 ms

So, although I might now not be so ashamed of my own code, I think the
relation python-boost basically still holds. Besides, I normally do
not use optimization switches, because I have deep running suspicions
about compiler optimizations that originate in traumatic experiences
with early c++ compilers about ten years ago, and those childhood
traumas are hard to come by (Does the name Glockenspiel ring a bell?) 

So, without optimizations, started without the debugger:

boost - 828 ms
ptools - 204 ms
strtok - 78 ms

Just prooves that good code should (c lib, ptools) should need no
compiler optimization. "Python -o" is now nearly twice the speed of
that boost code. 

(My machine is a Dual Athlon XP1900+, so it is expected to have better
absolute numbers than yours ;)



More information about the Python-list mailing list