g_timer_elapsed



Hi,
Pls check this code and its result:
Code:
#include <stdio.h>
#include <gtk\gtk.h>

int main(void) {
        GTimer *mytime;
        unsigned long msecs;
        double secs;
        unsigned long soma=1000;
        g_timer_reset(mytime);
        g_timer_start(mytime);
        for(;soma>0;soma--) g_print("duh");
        secs = g_timer_elapsed(mytime, &msecs);
        g_print("\n\n%d secs, %lu msecs", secs, msecs);
        return 0;
}


Result: ("duh" repeated 1000 times and...)
-927712936 secs, 1071103606 msecs


What kind of result is this?
Negative seconds??? As far as I can read in the manual:
gdouble     g_timer_elapsed                 (GTimer *timer,
                                              gulong *microseconds);

                   timer :
                          the timer.
            microseconds :
                          if non-NULL, this will be set to the
microseconds component of the elapsed time (it does not include the
number of seconds
                          elapsed).
                  Returns :
                          the elapsed time in seconds, as a double. 



It seems that it is not working. What's the problem?

Best regards,

-- 
+------------------Paulo J. Matos aka PDestroy--------------------+
|  ICQ # 361853  |  http://www.pdestroy.net | pdestroy netcabo pt |
|  http://iascp.sourceforge.net  |  http://mega.ist.utl.pt/~pocm  |
|  "Fixed width font LIVEZ!"     |  "Portability came to rule!"   |
+-----------------------------------------------------------------+




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]