Skip to content

Commit

Permalink
Improved profiler result printing. (#7709)
Browse files Browse the repository at this point in the history
* Fixed the regularization for BGU.

* Improved profiler result printing.

* Clang-format ain't liking pretty code.

* Clang-tidy ain't liking pretty code.

---------

Co-authored-by: Steven Johnson <srj@google.com>
  • Loading branch information
mcourteaux and steven-johnson authored Jul 26, 2023
1 parent 5749d8c commit bfc26cc
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions src/runtime/profiler_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,15 @@ WEAK void halide_profiler_report_unlocked(void *user_context, halide_profiler_st
}

if (print_f_states) {
int max_func_name_length = 0;
for (int i = 0; i < p->num_funcs; i++) {
halide_profiler_func_stats *fs = p->funcs + i;
int name_len = strlen(fs->name);
if (name_len > max_func_name_length) {
max_func_name_length = name_len;
}
}

for (int i = 0; i < p->num_funcs; i++) {
size_t cursor = 0;
sstr.clear();
Expand All @@ -378,17 +387,29 @@ WEAK void halide_profiler_report_unlocked(void *user_context, halide_profiler_st
}

sstr << " " << fs->name << ": ";
cursor += 25;
cursor += max_func_name_length + 5;
while (sstr.size() < cursor) {
sstr << " ";
}

float ft = fs->time / (p->runs * 1000000.0f);
if (ft < 10000) {
sstr << " ";
}
if (ft < 1000) {
sstr << " ";
}
if (ft < 100) {
sstr << " ";
}
if (ft < 10) {
sstr << " ";
}
sstr << ft;
// We don't need 6 sig. figs.
sstr.erase(3);
sstr << "ms";
cursor += 10;
cursor += 12;
while (sstr.size() < cursor) {
sstr << " ";
}
Expand Down

0 comments on commit bfc26cc

Please sign in to comment.