perlin
[vg.git] / vg_profiler.h
index 7be848aa3ee6937d930dc3f16fb7abd190594017..5c0690c9186b6010a0ecee9515fc9528cc2397a0 100644 (file)
@@ -13,8 +13,8 @@ struct vg_profile
 {
    const char *name;
 
-   u64 samples[ VG_PROFILE_SAMPLE_COUNT ];
-   u32 buffer_count, buffer_current;
+   u64    samples[ VG_PROFILE_SAMPLE_COUNT ];
+   u32    buffer_count, buffer_current;
 
    enum profile_mode
    {
@@ -78,8 +78,8 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
    ui_fill_rect( panel, 0xa0000000 );
 
    assert( count <= 8 );
-   float avgs[8];
-   int   ptrs[8];
+   double avgs[8];
+   int    ptrs[8];
 
    for( int i=0; i<count; i++ )
    {
@@ -94,7 +94,7 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
 
    for( int i=0; i<VG_PROFILE_SAMPLE_COUNT-1; i++ )
    {
-      float total = 0.0f;
+      double total = 0.0;
 
       for( int j=0; j<count; j++ )
       {
@@ -103,9 +103,9 @@ 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  = (double)profiles[j]->samples[ptrs[j]] * rate_mul,
-               px      = (total  / (budget)) * sw,
-               wx      = (sample / (budget)) * sw;
+         double sample  = (double)profiles[j]->samples[ptrs[j]] * rate_mul,
+                px      = (total  / (budget)) * sw,
+                wx      = (sample / (budget)) * sw;
 
          ui_rect block = { panel[0] + px, panel[1] + (float)i*sh,
                            wx,            sh };
@@ -120,6 +120,13 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
 
    char infbuf[64];
 
+   snprintf( infbuf, 64, "accuracy: %.7fms", rate_mul );
+   ui_text( (ui_rect){ panel[0] + 4,
+                       panel[1] + 0 * 14, 0, 0 }, 
+                       infbuf,
+                       1,
+                       k_text_align_left );
+
    for( int i=0; i<count; i++ )
    {
       snprintf( infbuf, 64, "%.4fms %s", 
@@ -136,10 +143,10 @@ VG_STATIC void vg_profile_drawn( struct vg_profile **profiles, u32 count,
 
 VG_STATIC void vg_profiler_init(void)
 {
-   vg_convar_push( (struct vg_convar){
+   vg_var_push( (struct vg_var){
       .name = "vg_profiler",
       .data = &vg_profiler,
-      .data_type = k_convar_dtype_i32,
+      .data_type = k_var_dtype_i32,
       .opt_i32 = { .min=0, .max=1, .clamp=1 },
       .persistent = 1
    });