Skip to content

Commit 6783e71

Browse files
committed
Support OSX without errors.
1 parent 20e9fd4 commit 6783e71

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

scripts/timer.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
#!/bin/bash
22

3+
function now_ms() {
4+
if [[ "$(uname)" == Darwin ]] ; then
5+
if [[ ! -z $(which gdate) ]] ; then
6+
gdate "+%s.%N"
7+
else
8+
python -c 'import time; print time.time()'
9+
fi
10+
else
11+
date "+%s.%N"
12+
fi
13+
}
14+
315
TIMINGS_FILE=/tmp/osrm.timings
416
NAME=$1
517
CMD=${@:2}
6-
START=$(date "+%s.%N")
18+
START=$(now_ms)
719
/bin/bash -c "$CMD"
8-
END=$(date "+%s.%N")
20+
END=$(now_ms)
921
TIME="$(echo "$END - $START" | bc)s"
10-
NEW_ENTRY="$NAME\t$TIME\t$(date -Iseconds)"
22+
NEW_ENTRY="$NAME\t$TIME\t$(date +%FT%X)"
1123

1224
echo -e "$NEW_ENTRY" >> $TIMINGS_FILE

0 commit comments

Comments
 (0)