00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <stdio.h>
00031 #include <glib.h>
00032 #include "browserLog.h"
00033 #include "timingInfo.h"
00034
00035
00036 static GTimer *theTimer = NULL;
00037
00038 int timing_init(void)
00039 {
00040 #ifdef TIMING_INFORMATION_ENABLED
00041 BR_LOGPRINTF("create timer");
00042 if (theTimer)
00043 {
00044 BR_ERRORPRINTF("create timer already called");
00045 }
00046 else
00047 {
00048 theTimer = g_timer_new();
00049 }
00050 #endif //TIMING_INFORMATION_ENABLED
00051 return 0;
00052 }
00053
00054 int timing_destroy(void)
00055 {
00056 #ifdef TIMING_INFORMATION_ENABLED
00057 BR_LOGPRINTF("destroy timer");
00058
00059 if (theTimer)
00060 {
00061 g_timer_destroy(theTimer);
00062 }
00063 #endif //TIMING_INFORMATION_ENABLED
00064 return 0;
00065 }
00066
00067 int timing_display_time_elapsed(void)
00068 {
00069 #ifdef TIMING_INFORMATION_ENABLED
00070 gulong microseconds = 0;
00071 gdouble seconds = 0;
00072
00073 if (theTimer)
00074 {
00075 seconds = g_timer_elapsed(theTimer, µseconds);
00076 BR_LOGPRINTF("######### time elapsed %f sec - %u usec ###########", seconds, microseconds);
00077 BR_LOGPRINTF("######### time elapsed %f sec ###########", seconds);
00078
00079
00080 g_timer_start(theTimer);
00081 }
00082
00083 #endif //TIMING_INFORMATION_ENABLED
00084 return 0;
00085
00086 }