From: GAMMELJL AT SLU DOT EDU Date: Mon, 22 Mar 1999 16:03:48 -0600 (CST) Subject: gprof To: djgpp AT delorie DOT com Message-id: <01J94XHB81SI90O3C2@SLU.EDU> Organization: SAINT LOUIS UNIVERSITY St. Louis, MO X-VMS-To: IN%"djgpp AT delorie DOT com" MIME-version: 1.0 Reply-To: djgpp AT delorie DOT com //I have noticed that C++ executables produced by the gxx //compiler and run in plain DOS are somewhat faster (15%) //than those produced by the g++ compiler and run in linux. //Nate Eldredge has told me that he does not see why that //should be so and has advised me to look at the times using //the profiler gprof available in djgpp and linux. But in //trying to follow his advice I found that djgpp is not //running gprof correctly. The timings seem to be //factor two (approximately) too low. //Here is a short program (test.cc) which proves my assertion //that djgpp is not running gprof correctly. Compile it in //djgpp with // gxx -pg test.cc -o test.exe //and then run it // C:\> test //and then profile it // C:\> gprof test.exe > file1 //(send output to file1 because the output usually too long to //view on screen). // //Compile it in linux with // # g++ -pg test.cc -o test.exe //and run it // # /directory/test.exe //where directory is the directory into which you put test.cc. //Profile it // # gprof test.exe > file1 //You will see that the timings done in the test code using time.h //say the total time required is about 32 seconds (200 mhz pentium //pro) whether one is running djgpp or linux. You will see that //the linux output of gprof confirms the 32 seconds and says that //main and zadd take about the same amount of time (16 seconds). //However, you will see that the djgpp output of gprof says that //main and zadd both take about 8 seconds, and that the total time //is about 16 seconds, all a factor two too low as I asserted. //My questions are: Is this a known problem? Have I made some //error? #include #include //use when timing (benchmarking) extern int zadd(void); unsigned int imax=400000000; main() {unsigned int i,j; clock_t start_time, end_time; //declaration statement for times start_time=clock(); //set start time for (i=1;i