Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved profiler result printing. #7709

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 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,21 @@ 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 << " ";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All "if" statements in Halide should be in {braces}, even trivial single-line ones like these

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, hmm. Then why doesn't the clang-format CI-step complain?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

clang-format didn't, but clang-tidy did

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, what, clang-tidy checks this separately. Clang-format has an option for this too, I believe.

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