Skip to content

Commit

Permalink
Fix subsecond runtime for integration tests. (7638cac)
Browse files Browse the repository at this point in the history
  • Loading branch information
blackwinter committed Mar 3, 2022
1 parent 49dde9a commit f8495c2
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions metafix/integrationTest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,22 @@ function run_catmandu() {
:
}

nanosecond_offset=-9
nanosecond_length=9
nanosecond_offset=-$nanosecond_length

function current_time() {
date +%s%N
}

function elapsed_time() {
local elapsed_time=$(($(current_time) - $1))
local elapsed_time=$(($(current_time) - $1)) seconds=0 milliseconds

if [ ${#elapsed_time} -gt $nanosecond_length ]; then
seconds=${elapsed_time:0:$nanosecond_offset}
else
elapsed_time=$(printf "%0${nanosecond_length}d" "$elapsed_time")
fi

local seconds=${elapsed_time:0:$nanosecond_offset} milliseconds
[ "$seconds" -lt 60 ] && milliseconds=".${elapsed_time:$nanosecond_offset:3}"

echo " ($(date "+%-Hh %-Mm %-S${milliseconds}s" -ud "@$seconds" | sed 's/^\(0[hm] \)*//'))"
Expand Down

0 comments on commit f8495c2

Please sign in to comment.