aboutsummaryrefslogtreecommitdiffstats
path: root/dist/travis/travis-utils.sh
diff options
context:
space:
mode:
Diffstat (limited to 'dist/travis/travis-utils.sh')
-rw-r--r--dist/travis/travis-utils.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/dist/travis/travis-utils.sh b/dist/travis/travis-utils.sh
new file mode 100644
index 000000000..8db013f7b
--- /dev/null
+++ b/dist/travis/travis-utils.sh
@@ -0,0 +1,23 @@
+# This is a trimmed down copy of
+# https://github.com/travis-ci/travis-build/blob/master/lib/travis/build/templates/header.sh
+travis_time_start() {
+ # `date +%N` returns the date in nanoseconds. It is used as a replacement for $RANDOM, which is only available in bash.
+ travis_timer_id=`date +%N`
+ travis_start_time=$(travis_nanoseconds)
+ echo "travis_time:start:$travis_timer_id"
+}
+travis_time_finish() {
+ travis_end_time=$(travis_nanoseconds)
+ local duration=$(($travis_end_time-$travis_start_time))
+ echo "travis_time:end:$travis_timer_id:start=$travis_start_time,finish=$travis_end_time,duration=$duration"
+}
+
+if [ "$TRAVIS_OS_NAME" = "osx" ]; then
+ travis_nanoseconds() {
+ date -u '+%s000000000'
+ }
+else
+ travis_nanoseconds() {
+ date -u '+%s%N'
+ }
+fi