Last active
August 29, 2015 13:57
-
-
Save kkarad/9677502 to your computer and use it in GitHub Desktop.
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 | |
#set -x | |
# Prints the date difference of "start" and "end" date in milliseconds | |
function datediff { | |
startsec=$(date -d "$1" +%s) | |
while [[ $startsec = 0* ]]; do startsec=${startsec#0}; done | |
endsec=$(date -d "$2" +%s) | |
while [[ $endsec = 0* ]]; do endsec=${endsec#0}; done | |
secdiff=$(($endsec - $startsec)) | |
startnano=$(date -d "$1" +%N) | |
while [[ $startnano = 0* ]]; do startnano=${startnano#0}; done | |
endnano=$(date -d "$2" +%N) | |
while [[ $endnano = 0* ]]; do endnano=${endnano#0}; done | |
nanosecdiff=$(($endnano - $startnano)) | |
echo $(((secdiff * 1000) + (nanosecdiff / 1000000))) | |
} | |
function mass_quote_ack_latency { | |
grep "MassQuote" | tr '\1' '-' | awk 'match($0, "117=([0-9]*.[0-9]*)",ary) {printf("%s %s %s %s\n",$1,$2,ary[1],$6)}' | sort -nk4 | awk '!(NR%2){printf("%s %s %s %s\n",p,$1,$2,$3)}{p=$1" "$2}' | while read d1 t1 d2 t2 rate; do dt1="$d1 $t1"; dt2="$d2 $t2"; diff=$(datediff "$dt1" "$dt2"); printf "%s ms = (%s - %s) %s\n" "$diff" "$dt1" "$dt2" "$rate"; done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment