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:
Aaron Gyes
2019-09-19 14:24:46 -07:00
parent 2b7b70a64f
commit 5c06e68115
2 changed files with 29 additions and 6 deletions

View File

@@ -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