Skip to content

Instantly share code, notes, and snippets.

@larsw
Created January 29, 2013 12:06
Show Gist options
  • Save larsw/4663774 to your computer and use it in GitHub Desktop.
Save larsw/4663774 to your computer and use it in GitHub Desktop.
awk arit. sum vs. string concat wtf?
for i in `seq 1 10`; do mono vectorizedquerytest.exe ; done | awk 'BEGIN { FS="."; OFMT="%d"; sum = 0; sumsq = 0; } ; {print $2;sum = sum + $2; sumsq = sumsq + $2*$2; } END { print "average:"; print sum / NR; print "std dev:"; print sqrt(sumsq/NR - (sum/NR)**2); }'
# the average/std dev output are fucked up in 19/20 times; it seems like awk sometimes does string concat, other times sum.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment