Skip to content

Instantly share code, notes, and snippets.

@lox
Created March 31, 2014 05:22
Show Gist options
  • Save lox/9885806 to your computer and use it in GitHub Desktop.
Save lox/9885806 to your computer and use it in GitHub Desktop.
Checks absolute times elapsed in a VM against currentmillis.com
#!/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