diff --git a/src/timer.cpp b/src/timer.cpp index e9e6114ea..454696385 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -8,7 +8,6 @@ #include #include #include -#include #include #include @@ -129,13 +128,13 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, auto unit_short_name = [](tunit unit) { switch (unit) { case tunit::minutes: - return "min"; + return "mins"; case tunit::seconds: - return "sec"; + return "secs"; case tunit::milliseconds: - return "ms"; + return "millis"; case tunit::microseconds: - return "\u03BCs"; + return "micros"; } // GCC does not recognize the exhaustive switch above return ""; @@ -153,7 +152,7 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, return micros / 1.0; } // GCC does not recognize the exhaustive switch above - return std::nan(""); + return 0.0; }; auto wall_unit = get_unit(net_wall_micros); @@ -166,9 +165,9 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, if (!verbose) { append_format(output, L"\n_______________________________" - L"\nDuration\t%6.3G %s:" - L"\n user time\t%6.3G %s" - L"\n kernel time\t%6.3G %s" + 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)); @@ -182,9 +181,9 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, append_format(output, L"\n________________________________________________________" - L"\nDuration %6.3G %s %*s %*s " - L"\n user time %6.3G %s %6.3G %s %6.3G %s " - L"\n kernel time %6.3G %s %6.3G %s %6.3G %s " + L"\nExecuted in %6.2F %s %*s %*s " + L"\n usr time %6.2F %s %6.2F %s %6.2F %s " + L"\n sys time %6.2F %s %6.2F %s %6.2F %s " L"\n", wall_time, unit_short_name(wall_unit), strlen(unit_short_name(wall_unit)) - 1, "fish", strlen(unit_short_name(fish_unit)) - 1, "external", usr_time, diff --git a/tests/checks/time.fish b/tests/checks/time.fish index d28f7461d..486108911 100644 --- a/tests/checks/time.fish +++ b/tests/checks/time.fish @@ -4,9 +4,9 @@ time sleep 0 # These are a tad awkward because it picks the correct unit and adapts whitespace. # The idea is that it's a table. #CHECKERR: ________________________________________________________ -#CHECKERR: Duration {{[\d,.\s]*}} {{ms|μs|sec}} {{\s*}}fish {{\s*}}external -#CHECKERR: user time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} -#CHECKERR: kernel time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} +#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external +#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} +#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} time for i in (seq 1 2) echo banana end @@ -14,17 +14,17 @@ end #CHECK: banana #CHECK: banana #CHECKERR: ________________________________________________________ -#CHECKERR: Duration {{[\d,.\s]*}} {{ms|μs|sec}} {{\s*}}fish {{\s*}}external -#CHECKERR: user time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} -#CHECKERR: kernel time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} +#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external +#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} +#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} # Make sure we're not double-parsing time echo 'foo -s bar' #CHECK: foo -s bar #CHECKERR: ________________________________________________________ -#CHECKERR: Duration {{[\d,.\s]*}} {{ms|μs|sec}} {{\s*}}fish {{\s*}}external -#CHECKERR: user time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} -#CHECKERR: kernel time {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} {{[\d,.\s]*}} {{ms|μs|sec}} +#CHECKERR: Executed in {{[\d,.\s]*}} {{millis|micros|secs}} {{\s*}}fish {{\s*}}external +#CHECKERR: usr time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} +#CHECKERR: sys time {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} {{[\d,.\s]*}} {{millis|micros|secs}} true && time a=b not builtin true | true #CHECKERR: ___{{.*}}