aboutsummaryrefslogtreecommitdiff
path: root/src/timings.cpp
diff options
context:
space:
mode:
authorGinger Bill <bill@gingerbill.org>2017-07-07 15:26:49 +0100
committerGinger Bill <bill@gingerbill.org>2017-07-07 15:26:49 +0100
commit773cf5ca08de0476b0b8b1ae4c25ac6da62a8059 (patch)
tree203717ab20c5772f5b4ae720ed8f92df504f6340 /src/timings.cpp
parent2db03cb4a54eaa594ca0d3ccb6819a8d56e7efed (diff)
Add `-show-timings`; Clean up polymorphic procedure code a bit
Diffstat (limited to 'src/timings.cpp')
-rw-r--r--src/timings.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/timings.cpp b/src/timings.cpp
index 27ee1f3a4..78fdd5240 100644
--- a/src/timings.cpp
+++ b/src/timings.cpp
@@ -8,6 +8,7 @@ struct Timings {
TimeStamp total;
Array<TimeStamp> sections;
u64 freq;
+ f64 total_time_seconds;
};
@@ -123,16 +124,21 @@ void timings_print_all(Timings *t) {
GB_ASSERT(max_len <= gb_size_of(SPACES)-1);
- gb_printf("%.*s%.*s - %.3f ms\n",
+ t->total_time_seconds = cast(f64)(t->total.finish - t->total.start) / cast(f64)t->freq;
+
+ f64 total_ms = time_stamp_as_ms(t->total, t->freq);
+
+ gb_printf("%.*s%.*s - % 9.3f ms\n",
LIT(t->total.label),
cast(int)(max_len-t->total.label.len), SPACES,
- time_stamp_as_ms(t->total, t->freq));
+ total_ms);
for_array(i, t->sections) {
TimeStamp ts = t->sections[i];
- gb_printf("%.*s%.*s - %.3f ms\n",
+ f64 section_ms = time_stamp_as_ms(ts, t->freq);
+ gb_printf("%.*s%.*s - % 9.3f ms - %5.2f%%\n",
LIT(ts.label),
cast(int)(max_len-ts.label.len), SPACES,
- time_stamp_as_ms(ts, t->freq));
+ section_ms, 100*section_ms/total_ms);
}
}