sync clean up
[vg.git] / vg_profiler.h
index 784fc287ebf7ea0297dda48276f04a502f21c5ab..7be848aa3ee6937d930dc3f16fb7abd190594017 100644 (file)
@@ -1,6 +1,7 @@
 #ifndef VG_PROFILER_H
 #define VG_PROFILER_H
 
+#define VG_GAME
 #include "vg.h"
 #include "vg_platform.h"
 
@@ -12,7 +13,7 @@ struct vg_profile
 {
    const char *name;
 
-   u32 samples[ VG_PROFILE_SAMPLE_COUNT ];
+   u64 samples[ VG_PROFILE_SAMPLE_COUNT ];
    u32 buffer_count, buffer_current;
 
    enum profile_mode
@@ -40,15 +41,13 @@ VG_STATIC void vg_profile_increment( struct vg_profile *profile )
    if( profile->buffer_current >= VG_PROFILE_SAMPLE_COUNT )
       profile->buffer_current = 0;
 
-   profile->samples[ profile->buffer_current ] = 0.0f;
+   profile->samples[ profile->buffer_current ] = 0;
 }
 
 VG_STATIC void vg_profile_end( struct vg_profile *profile )
 {
-   u64 time_end;
-
-   time_end = SDL_GetPerformanceCounter();
-   u64 delta = profile->start - time_end;
+   u64 time_end = SDL_GetPerformanceCounter(),
+       delta    = time_end - profile->start;
 
    if( profile->mode == k_profile_mode_frame )
    {
@@ -91,7 +90,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
    u32 colours[] = { 0xff0000ff, 0xff00ff00, 0xff00ffff, 0xffff0000,
                      0xffff00ff, 0xffffff00 };
 
-   float rate_mul = 1.0f / (float)SDL_GetPerformanceFrequency();
+   double rate_mul = 1000.0 / (double)SDL_GetPerformanceFrequency();
 
    for( int i=0; i<VG_PROFILE_SAMPLE_COUNT-1; i++ )
    {
@@ -104,7 +103,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
          if( ptrs[j] < 0 )
             ptrs[j] = VG_PROFILE_SAMPLE_COUNT-1;
 
-         float sample  = (float)profiles[j]->samples[ptrs[j]] * rate_mul,
+         float sample  = (double)profiles[j]->samples[ptrs[j]] * rate_mul,
                px      = (total  / (budget)) * sw,
                wx      = (sample / (budget)) * sw;