mirror of
https://github.com/fish-shell/fish-shell.git
synced 2026-04-20 16:11:14 -03:00
tests: add a lame gdate-based ms-precision timer if installed
I got tired of seeing ' ... ok (0 sec)' so now with GNU date/gdate installed there is millisecond output shown. One can get rough nanoseconds from gdate.
This commit is contained in:
@@ -133,3 +133,26 @@ function colordiff -d 'Colored diff output for unified diffs'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# lame timer
|
||||
for program in {g,}date
|
||||
if $program --version
|
||||
set milli $program
|
||||
set unit ms
|
||||
break
|
||||
else
|
||||
set unit sec
|
||||
end
|
||||
end
|
||||
|
||||
function timestamp -V milli
|
||||
set -q milli[1]
|
||||
and $milli +%s%3N
|
||||
or date +%s
|
||||
end
|
||||
|
||||
function delta -V milli
|
||||
set -q milli[1]
|
||||
and math "( "($milli +%s%3N)" - $argv[1])"
|
||||
or math (date +%s) - $starttime
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user