|
From: Seth D. <set...@us...> - 2005-01-16 00:30:31
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31421/source Modified Files: timedate.c Log Message: Performance tweak. getmilliseconds() now stores the performance frequency in a global, and only sets it if the value is 0. QueryPerformanceFrequency always returns the same result (on a given machine), there is no point to calling it every time we need the milliseconds. Index: timedate.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/timedate.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** timedate.c 15 Jan 2005 20:39:21 -0000 1.9 --- timedate.c 16 Jan 2005 00:30:19 -0000 1.10 *************** *** 122,125 **** --- 122,127 ---- static tyinternationalinfo globalII; static tyinternationalinfoptr globalIIptr = NULL; + + static LONGLONG gPerformanceFreq = 0; /* for getmilliseconds() */ #endif *************** *** 1554,1567 **** extern long getmilliseconds(void) { ! LARGE_INTEGER counter, freq; ! LONGLONG freqLong; QueryPerformanceCounter (&counter); /* counter hits since boot-up */ ! QueryPerformanceFrequency (&freq); /* frequency of coutner hits (per second) */ ! ! freqLong = ( freq.LowPart | ( freq.HighPart << 32 ) ) / 1000; /* per millisecond */ ! return ((long) ((counter.LowPart | (counter.HighPart << 32)) / freqLong)); } /* getmilliseconds */ --- 1556,1570 ---- extern long getmilliseconds(void) { ! LARGE_INTEGER counter; QueryPerformanceCounter (&counter); /* counter hits since boot-up */ ! if (gPerformanceFreq == 0) { ! LARGE_INTEGER freq; ! QueryPerformanceFrequency (&freq); /* frequency of coutner hits (per second) */ ! gPerformanceFreq = freq.QuadPart / 1000; ! } ! return ((long) (counter.QuadPart / gPerformanceFreq)); } /* getmilliseconds */ |