diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2014-10-16 06:54:36 -0700 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2014-10-16 06:54:36 -0700 |
commit | 21b97d490625b016243aea4d2d627040de8879c3 (patch) | |
tree | 4df78a357a84571868d8eca5e7bf905f869a42ee /scripts/travis_helper.sh | |
parent | 42b54b11d8f90aeeb7fd37309a06de91553caa6b (diff) | |
download | qtlocation-mapboxgl-21b97d490625b016243aea4d2d627040de8879c3.tar.gz |
better timing functions
Diffstat (limited to 'scripts/travis_helper.sh')
-rwxr-xr-x | scripts/travis_helper.sh | 42 |
1 files changed, 33 insertions, 9 deletions
diff --git a/scripts/travis_helper.sh b/scripts/travis_helper.sh index ebe1e965b5..040ef29443 100755 --- a/scripts/travis_helper.sh +++ b/scripts/travis_helper.sh @@ -1,17 +1,41 @@ #!/usr/bin/env bash +function mapbox_time_start { + local name=$1 + mapbox_timer_name=$name + + travis_fold start $name + + mapbox_timer_id=$(printf %08x $(( RANDOM * RANDOM ))) + eval "mapbox_start_time_$mapbox_timer_id=$(travis_nanoseconds)" + echo -en "travis_time:start:$mapbox_timer_id\n" +} + +function mapbox_time_finish { + local name=${1:-$mapbox_timer_name} + local timer_id=${2:-$mapbox_timer_id} + local timer_start="mapbox_start_time_$timer_id" + eval local start_time=\${$timer_start} + local end_time=$(travis_nanoseconds) + local duration=$(($end_time-$start_time)) + echo -en "travis_time:end:$timer_id:start=$start_time,finish=$end_time,duration=$duration\n" + + travis_fold end $name +} + function mapbox_time { - local NAME=$1 ; shift - travis_fold start "${NAME}" - travis_time_start - "$@" - travis_time_finish - travis_fold end "${NAME}" + local name=$1 ; shift + mapbox_time_start $name + local timer_id=$mapbox_timer_id + echo "\$ $@" + $@ + mapbox_time_finish $name $timer_id } + +export ANSI_CLEAR export -f travis_fold -export -f travis_time_start -export -f travis_time_finish export -f travis_nanoseconds -export ANSI_CLEAR export -f mapbox_time +export -f mapbox_time_start +export -f mapbox_time_finish |