Profiler: Use ProfileModel rounding constant for the status bar text

This way, we can change the constant in one place. Note that this
requires the use of nested format strings, which is slightly ugly but
safe to do in this instance.
This commit is contained in:
kleines Filmröllchen 2022-04-26 22:59:03 +02:00 committed by Linus Groh
parent 6368ef41f8
commit 71b175d4ed
Notes: sideshowbarker 2024-07-17 11:12:16 +09:00

View file

@ -222,9 +222,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return min(end_of_trace, max(timestamp, start_of_trace));
};
auto const format_sample_count = [&profile](auto sample_count) {
// FIXME: Make this constexpr once String is able to.
auto const sample_count_percent_format_string = String::formatted("{{:.{}f}}%", number_of_percent_digits);
auto const format_sample_count = [&profile, sample_count_percent_format_string](auto const sample_count) {
if (profile->show_percentages())
return String::formatted("{:.3f}%", sample_count.as_float_or(0.0));
return String::formatted(sample_count_percent_format_string, sample_count.as_float_or(0.0));
return String::formatted("{} Samples", sample_count.to_i32());
};