[timings-export] Implement JSON + CSV timngs export.

This commit is contained in:
Jeroen van Rijn
2021-11-09 19:50:23 +01:00
parent 9422fd311f
commit 05a86d5296
2 changed files with 121 additions and 10 deletions

View File

@@ -169,14 +169,19 @@ f64 time_stamp(TimeStamp const &ts, u64 freq, TimingUnit unit) {
}
}
void timings_print_all(Timings *t, TimingUnit unit = TimingUnit_Millisecond) {
void timings_print_all(Timings *t, TimingUnit unit = TimingUnit_Millisecond, bool timings_are_finalized = false) {
isize const SPACES_LEN = 256;
char SPACES[SPACES_LEN+1] = {0};
gb_memset(SPACES, ' ', SPACES_LEN);
timings__stop_current_section(t);
t->total.finish = time_stamp_time_now();
/*
NOTE(Jeroen): Whether we call `timings_print_all()`, then `timings_export_all()`, the other way around,
or just one of them, we only need to stop the clock once.
*/
if (!timings_are_finalized) {
timings__stop_current_section(t);
t->total.finish = time_stamp_time_now();
}
isize max_len = gb_min(36, t->total.label.len);
for_array(i, t->sections) {
@@ -207,4 +212,4 @@ void timings_print_all(Timings *t, TimingUnit unit = TimingUnit_Millisecond) {
timing_unit_strings[unit],
100.0*section_time/total_time);
}
}
}