FreeBASIC  0.91.0
time_timer.c
Go to the documentation of this file.
1 /* timer() function */
2 
3 #include "../fb.h"
4 #include <time.h>
5 #include <windows.h>
6 
7 #define TIMER_NONE 0
8 #define TIMER_NORMAL 1
9 #define TIMER_HIGHRES 2
10 static int timer = TIMER_NONE;
11 static double frequency;
12 
13 FBCALL double fb_Timer( void )
14 {
15  LARGE_INTEGER count;
16 
17  if( timer == TIMER_NONE ) {
18  if( QueryPerformanceFrequency( &count ) ) {
19  frequency = 1.0 / (double)count.QuadPart;
21  } else {
23  }
24  }
25 
26  if( timer == TIMER_NORMAL ) {
27  return (double)GetTickCount( ) * 0.001;
28  } else {
29  QueryPerformanceCounter( &count );
30  return (double)count.QuadPart * frequency;
31  }
32 }