mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-29 06:13:20 +00:00
timer.cpp: fix format specifiers and type confusion
I think the auto-all-the-things here was a making this a little hard to follow, so replace these things that will be used in printf with what they really are. And change the * lengths to ints. should clear up the alerts.
This commit is contained in:
parent
2b736d023f
commit
9b9e2f9f87
1 changed files with 20 additions and 20 deletions
|
@ -157,30 +157,31 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
|||
|
||||
auto wall_unit = get_unit(net_wall_micros);
|
||||
auto cpu_unit = get_unit(std::max(net_sys_micros, net_usr_micros));
|
||||
auto wall_time = convert(net_wall_micros, wall_unit);
|
||||
auto usr_time = convert(net_usr_micros, cpu_unit);
|
||||
auto sys_time = convert(net_sys_micros, cpu_unit);
|
||||
double wall_time = convert(net_wall_micros, wall_unit);
|
||||
double usr_time = convert(net_usr_micros, cpu_unit);
|
||||
double sys_time = convert(net_sys_micros, cpu_unit);
|
||||
|
||||
wcstring output;
|
||||
if (!verbose) {
|
||||
append_format(output,
|
||||
L"\n_______________________________"
|
||||
L"\nExecuted in %6.2F %s"
|
||||
L"\n usr time %6.2F %s"
|
||||
L"\n sys time %6.2F %s"
|
||||
L"\n",
|
||||
wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), sys_time,
|
||||
unit_name(cpu_unit));
|
||||
append_format(output, L"\n_______________________________"
|
||||
L"\nExecuted in %6.2F %s"
|
||||
L"\n usr time %6.2F %s"
|
||||
L"\n sys time %6.2F %s"
|
||||
L"\n",
|
||||
wall_time, unit_name(wall_unit),
|
||||
usr_time, unit_name(cpu_unit),
|
||||
sys_time, unit_name(cpu_unit));
|
||||
} else {
|
||||
auto fish_unit = get_unit(std::max(fish_sys_micros, fish_usr_micros));
|
||||
auto child_unit = get_unit(std::max(child_sys_micros, child_usr_micros));
|
||||
auto fish_usr_time = convert(fish_usr_micros, fish_unit);
|
||||
auto fish_sys_time = convert(fish_sys_micros, fish_unit);
|
||||
auto child_usr_time = convert(child_usr_micros, child_unit);
|
||||
auto child_sys_time = convert(child_sys_micros, child_unit);
|
||||
double fish_usr_time = convert(fish_usr_micros, fish_unit);
|
||||
double fish_sys_time = convert(fish_sys_micros, fish_unit);
|
||||
double child_usr_time = convert(child_usr_micros, child_unit);
|
||||
double child_sys_time = convert(child_sys_micros, child_unit);
|
||||
|
||||
auto column2_unit_len =
|
||||
std::max(strlen(unit_short_name(wall_unit)), strlen(unit_short_name(cpu_unit)));
|
||||
int column2_unit_len = std::max(strlen(unit_short_name(wall_unit)),
|
||||
strlen(unit_short_name(cpu_unit)));
|
||||
// TODO: improve layout and use standard two char units
|
||||
append_format(output,
|
||||
L"\n________________________________________________________"
|
||||
L"\nExecuted in %6.2F %-*s %-*s %s"
|
||||
|
@ -188,13 +189,12 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
|||
L"\n sys time %6.2F %-*s %6.2F %s %6.2F %s"
|
||||
L"\n",
|
||||
wall_time, column2_unit_len, unit_short_name(wall_unit),
|
||||
strlen(unit_short_name(fish_unit)) + 7, "fish", "external", //
|
||||
usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time, //
|
||||
static_cast<int>(strlen(unit_short_name(fish_unit))) + 7, "fish", "external",
|
||||
usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time,
|
||||
unit_short_name(fish_unit), child_usr_time, unit_short_name(child_unit),
|
||||
sys_time, column2_unit_len, unit_short_name(cpu_unit), fish_sys_time,
|
||||
unit_short_name(fish_unit), child_sys_time, unit_short_name(child_unit));
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue