Web lists-archives.com

Re: [Mingw-users] Strange gprof results




Manolo to Anton Shepelev:

>>while  they  clearly  take different times to com-
>>plete.
>
>How do you know this? Have you measured times?

I measured the times manually, but here I do  it  in
the code:

   #include "test.h"
   #include <stdlib.h>
   #include <stdio.h>
   #include <time.h>

   void genwait( unsigned t )
   {    clock_t before, after;
        unsigned i;
        char line[3];
        double time_sec;
        before = clock();
        for( i = 0; i < t; i++ )
        {    sprintf(line, "a");  }
        after = clock();
        time_sec = ((double)(after - before)) / CLOCKS_PER_SEC;
        printf( "%i cycles took %2.3g seconds.\n", t, time_sec );
   }

   void wait1()
   {    genwait(100000000);  }

   void wait2()
   {    genwait(800000000);  }

   void wait3()
   {    genwait(1600000000);  }

   void WorkHard()
   {    int i=0;
        wait1();
        wait2();
        wait3();
   }

And the program outputs different execution times:

   100000000 cycles took 0.344 seconds.
   800000000 cycles took 2.86 seconds.
   1600000000 cycles took 5.7 seconds.

The modified test sample is here:

         http://preview.tinyurl.com/jdtecwk

but  gprof still shows the average time of about 2.7
seconds for each test run.


------------------------------------------------------------------------------
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe