aboutsummaryrefslogtreecommitdiffstats
path: root/code/base/base_os.c
blob: e5364154c4648bd5372bdaaaf588203882521258 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#if OS_LINUX || OS_ANDROID
# include "base_os_linux.c"
#elif OS_WINDOWS
# include "base_os_windows.c"
#else 
# error "Operating system not provided or supported."
#endif

internal inline f64
OS_SecondsElapsed(f64 Start, f64 End)
{
    f64 Result = (End - Start);
    return Result;
}

internal inline f64
OS_MSElapsed(f64 Start, f64 End)
{
    f64 Result = ((End - Start)*1000.0);
    return Result;
}

internal void
OS_ProfileInit(char *Prefix)
{
    GlobalProfiler.Start = OS_GetWallClock();
    GlobalProfiler.End = GlobalProfiler.Start;
    GlobalProfilerPrefix = Prefix;
}

internal void
OS_ProfileAndPrint(char *Label)
{
    if(GlobalIsProfiling)
    {        
        GlobalProfiler.End = OS_GetWallClock();
        Log(" %s_%s: %.4f\n", GlobalProfilerPrefix, Label, OS_MSElapsed(GlobalProfiler.Start, GlobalProfiler.End));
        GlobalProfiler.Start = GlobalProfiler.End;
    }
}