diff --git a/src/timer.cpp b/src/timer.cpp index 454696385..e9e6114ea 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -128,13 +129,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 "mins"; + return "min"; case tunit::seconds: - return "secs"; + return "sec"; case tunit::milliseconds: - return "millis"; + return "ms"; case tunit::microseconds: - return "micros"; + return "\u03BCs"; } // GCC does not recognize the exhaustive switch above return ""; @@ -152,7 +153,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 0.0; + return std::nan(""); }; auto wall_unit = get_unit(net_wall_micros); @@ -165,9 +166,9 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, 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"\nDuration\t%6.3G %s:" + L"\n user time\t%6.3G %s" + L"\n kernel time\t%6.3G %s" L"\n", wall_time, unit_name(wall_unit), usr_time, unit_name(cpu_unit), sys_time, unit_name(cpu_unit)); @@ -181,9 +182,9 @@ wcstring timer_snapshot_t::print_delta(timer_snapshot_t t1, timer_snapshot_t t2, append_format(output, L"\n________________________________________________________" - 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"\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"\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 486108911..d28f7461d 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: 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}} +#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}} time for i in (seq 1 2) echo banana end @@ -14,17 +14,17 @@ end #CHECK: banana #CHECK: banana #CHECKERR: ________________________________________________________ -#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}} +#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}} # Make sure we're not double-parsing time echo 'foo -s bar' #CHECK: foo -s bar #CHECKERR: ________________________________________________________ -#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}} +#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}} true && time a=b not builtin true | true #CHECKERR: ___{{.*}}