[comp.lang.c++] Strange result from gprof++

euamts@eua.ericsson.se (Mats Henricson) (05/23/91)

Hi!

I have this string-class that I wanted to test some performance on.
On several places in the implementation it is tested if the user
tries to index out of bounds when extracting substrings or single
characters. So I wanted to see how much time I could save the user
by providing a string-class for those that claim that they never
make indexing-mistakes.

I have this really large test-program for my string-class, and I
tested how long time it took to execute it 10000 times with and without
the index-out-of-bounds checks. I used the gprof++ program with the
-pg option of cc. I also tried with and without the optimizing -O
option. ALL tests claim that the string-class WITH the testing code
is FASTER than the class without tests. As you all can see I am
fairly confused.

Is there anyone out there that knows why this could be?

Facts:
1. Sparcstation 2
2. Sun OS 4.1.1
3. gprof++ (release 4.1 ?? (man-page says 20 july 1989))
4. Sun C++ 2.0
5. The different string-classes tested alone, i.e. not at the same
   time in the same test-program

Mats Henricson