Created
March 31, 2014 05:22
-
-
Save lox/9885806 to your computer and use it in GitHub Desktop.
Checks absolute times elapsed in a VM against currentmillis.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
SAMPLES=5 | |
OVERHEAD=600 # about 600ms of overhead from AU for the service below | |
function remote_millis() { | |
curl --silent http://currentmillis.com/api/millis-since-unix-epoch.php | |
} | |
for i in {1..10} ; do | |
for u in $(eval echo "{1..$SAMPLES}") ; do | |
echo -n "sleeping for $i seconds... " | |
before=$(remote_millis) | |
localtimer=$(TIMEFORMAT=%R; (time sleep $i) 2>&1) | |
after=$(remote_millis) | |
echo -n "${localtimer}s elapsed locally, " | |
echo "$(($after - $before - $OVERHEAD))ms remotely" | |
done | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment