#include "df_hi_res_time.h"

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>


static double g_tickInterval = -1.0;
static double g_timeShift = 0.0;


inline double GetLowLevelTime();


static void InitialiseHighResTime()
{
    LARGE_INTEGER count;
    QueryPerformanceFrequency(&count);
    g_tickInterval = 1.0 / (double)count.QuadPart;
	g_timeShift = GetLowLevelTime();
}


inline double GetLowLevelTime()
{
    if (g_tickInterval < 0.0)
        InitialiseHighResTime();

    LARGE_INTEGER count;
    QueryPerformanceCounter(&count);
    return (double)count.QuadPart * g_tickInterval;
}


double GetHighResTime()
{
	double timeNow = GetLowLevelTime();
    timeNow -= g_timeShift;
    return timeNow;
}


void SleepMillisec(int milliseconds)
{
	Sleep(milliseconds);
}

#include "df_hi_res_time.h"

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>


static double g_tickInterval = -1.0;
static double g_timeShift = 0.0;


inline double GetLowLevelTime();


static void InitialiseHighResTime()
{
    LARGE_INTEGER count;
    QueryPerformanceFrequency(&count);
    g_tickInterval = 1.0 / (double)count.QuadPart;
	g_timeShift = GetLowLevelTime();
}


inline double GetLowLevelTime()
{
    if (g_tickInterval < 0.0)
        InitialiseHighResTime();

    LARGE_INTEGER count;
    QueryPerformanceCounter(&count);
    return (double)count.QuadPart * g_tickInterval;
}


__declspec(noinline) double GetHighResTime()
{
	double timeNow = GetLowLevelTime();
    timeNow -= g_timeShift;
    return timeNow;
}


void SleepMillisec(int milliseconds)
{
	Sleep(milliseconds);
}

Make sure GetHighResTime() doesn't get inlined because it is a slow function anyway since it calls QueryPerformanceCounter(). Also, it is often used when profiling, and when it gets inlined, it makes the disassembly look confusing.
Make sure GetHighResTime() doesn't get inlined because it is a slow function anyway since it calls QueryPerformanceCounter(). Also, it is often used when profiling, and when it gets inlined, it makes the disassembly look confusing.