Ylva And Malin
ym_time.h
Go to the documentation of this file.
1 #pragma once
2 #include <stddef.h>
3 #include <stdio.h>
4 #include <time.h>
5 
6 #ifdef WIN32
7 #include <Windows.h>
8 #else
9 #include <sys/sysinfo.h>
10 #include <sys/time.h>
11 #endif
12 
14 double
16 {
17  #ifdef WIN32
18  LARGE_INTEGER frequency;
19  LARGE_INTEGER time;
20  QueryPerformanceFrequency(&frequency);
21  QueryPerformanceCounter(&time);
22 
23  // Multiply to avoid loss-of-precision
24  time.QuadPart *= 1E6;
25  time.QuadPart /= frequency.QuadPart;
26 
27  // Divide to convert from microseconds to seconds.
28  return time.QuadPart / 1E6;
29 
30  #else
31  struct timeval tp;
32  gettimeofday(&tp, NULL);
33 
34  return (double)tp.tv_sec + (double)tp.tv_usec / 1E6;
35  #endif
36 }
#define YM_INLINE
YM_INLINE is a platform independent macro that forces a function to be inlined.
Definition: ym_attributes.h:31
YM_INLINE double ym_clock_now()
Definition: ym_time.h:15