mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-20 05:48:47 +08:00
time: use box drawing characterts for the separator
This spruces up output slightly to render a solid line instead of a bunch of dashes for the horizontal rule shown in time output.
This commit is contained in:
parent
2d9e51b43e
commit
346ce8081b
|
@ -11,6 +11,19 @@
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
#if HAVE_CURSES_H
|
||||||
|
#include <curses.h>
|
||||||
|
#elif HAVE_NCURSES_H
|
||||||
|
#include <ncurses.h>
|
||||||
|
#elif HAVE_NCURSES_CURSES_H
|
||||||
|
#include <ncurses/curses.h>
|
||||||
|
#endif
|
||||||
|
#if HAVE_TERM_H
|
||||||
|
#include <term.h>
|
||||||
|
#elif HAVE_NCURSES_TERM_H
|
||||||
|
#include <ncurses/term.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "builtin.h"
|
#include "builtin.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
#include "exec.h"
|
#include "exec.h"
|
||||||
|
@ -122,7 +135,7 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
||||||
return L"microseconds";
|
return L"microseconds";
|
||||||
}
|
}
|
||||||
// GCC does not recognize the exhaustive switch above
|
// GCC does not recognize the exhaustive switch above
|
||||||
return "";
|
return L"";
|
||||||
};
|
};
|
||||||
|
|
||||||
auto unit_short_name = [](tunit unit) {
|
auto unit_short_name = [](tunit unit) {
|
||||||
|
@ -137,7 +150,7 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
||||||
return L"μs";
|
return L"μs";
|
||||||
}
|
}
|
||||||
// GCC does not recognize the exhaustive switch above
|
// GCC does not recognize the exhaustive switch above
|
||||||
return "";
|
return L"";
|
||||||
};
|
};
|
||||||
|
|
||||||
auto convert = [](int64_t micros, tunit unit) {
|
auto convert = [](int64_t micros, tunit unit) {
|
||||||
|
@ -163,10 +176,9 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
||||||
|
|
||||||
wcstring output;
|
wcstring output;
|
||||||
if (!verbose) {
|
if (!verbose) {
|
||||||
append_format(output, L"\n_______________________________"
|
append_format(output, L"\nExecuted in %6.2F %ls"
|
||||||
L"\nExecuted in %6.2F %s"
|
L"\n usr time %6.2F %ls"
|
||||||
L"\n usr time %6.2F %s"
|
L"\n sys time %6.2F %ls"
|
||||||
L"\n sys time %6.2F %s"
|
|
||||||
L"\n",
|
L"\n",
|
||||||
wall_time, unit_name(wall_unit),
|
wall_time, unit_name(wall_unit),
|
||||||
usr_time, unit_name(cpu_unit),
|
usr_time, unit_name(cpu_unit),
|
||||||
|
@ -180,16 +192,16 @@ wcstring timer_snapshot_t::print_delta(const timer_snapshot_t &t1, const timer_s
|
||||||
double child_sys_time = convert(child_sys_micros, child_unit);
|
double child_sys_time = convert(child_sys_micros, child_unit);
|
||||||
|
|
||||||
int column2_unit_len = std::max(wcslen(unit_short_name(wall_unit)),
|
int column2_unit_len = std::max(wcslen(unit_short_name(wall_unit)),
|
||||||
strlen(unit_short_name(cpu_unit)));
|
wcslen(unit_short_name(cpu_unit)));
|
||||||
// TODO: improve layout and use standard two char units
|
// TODO: improve layout
|
||||||
append_format(output,
|
append_format(output,
|
||||||
L"\n________________________________________________________"
|
L"%s%s%s"
|
||||||
L"\nExecuted in %6.2F %-*ls %-*s %s"
|
L"\nExecuted in %6.2F %-*ls %-*s %s"
|
||||||
L"\n usr time %6.2F %-*ls %6.2F %ls %6.2F %ls"
|
L"\n usr time %6.2F %-*ls %6.2F %ls %6.2F %ls"
|
||||||
L"\n sys time %6.2F %-*ls %6.2F %ls %6.2F %ls"
|
L"\n sys time %6.2F %-*ls %6.2F %ls %6.2F %ls",
|
||||||
L"\n",
|
enter_alt_charset_mode, std::string(45, 'q').c_str(), exit_alt_charset_mode,
|
||||||
wall_time, column2_unit_len, unit_short_name(wall_unit),
|
wall_time, column2_unit_len, unit_short_name(wall_unit),
|
||||||
static_cast<int>(strlen(unit_short_name(fish_unit))) + 7, "fish", "external",
|
static_cast<int>(wcslen(unit_short_name(fish_unit))) + 7, "fish", "external",
|
||||||
usr_time, column2_unit_len, unit_short_name(cpu_unit), fish_usr_time,
|
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),
|
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,
|
sys_time, column2_unit_len, unit_short_name(cpu_unit), fish_sys_time,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user