Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!nstn.ns.ca!news.cs.indiana.edu!samsung!usc!elroy.jpl.nasa.gov!ncar!gatech!bloom-beacon!eru!hagbard!sunic!ericom!eua.ericsson.se!euamts From: euamts@eua.ericsson.se (Mats Henricson) Newsgroups: comp.lang.c++ Subject: Strange result from gprof++ Message-ID: <1991May23.144922.19743@eua.ericsson.se> Date: 23 May 91 14:49:22 GMT Sender: news@eua.ericsson.se Organization: Ellemtel Telecom Systems Labs, Stockholm, Sweden Lines: 28 Nntp-Posting-Host: euas20c01.eua.ericsson.se 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