bench.sh 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/bin/bash
  2. # for a given node version run:
  3. # for i in {0..9}; do node benchmark.js >> bench_0.6.2.log; done;
  4. PATTERNS=('nodeuuid.v1()' "nodeuuid.v1('binary'," 'nodeuuid.v4()' "nodeuuid.v4('binary'," "uuid()" "uuid('binary')" 'uuidjs.create(1)' 'uuidjs.create(4)' '140byte')
  5. FILES=(node_uuid_v1_string node_uuid_v1_buf node_uuid_v4_string node_uuid_v4_buf libuuid_v4_string libuuid_v4_binary uuidjs_v1_string uuidjs_v4_string 140byte_es)
  6. INDICES=(2 3 2 3 2 2 2 2 2)
  7. VERSIONS=$( ls bench_*.log | sed -e 's/^bench_\([0-9\.]*\)\.log/\1/' | tr "\\n" " " )
  8. TMPJOIN="tmp_join"
  9. OUTPUT="bench_results.txt"
  10. for I in ${!FILES[*]}; do
  11. F=${FILES[$I]}
  12. P=${PATTERNS[$I]}
  13. INDEX=${INDICES[$I]}
  14. echo "version $F" > $F
  15. for V in $VERSIONS; do
  16. (VAL=$( grep "$P" bench_$V.log | LC_ALL=en_US awk '{ sum += $'$INDEX' } END { print sum/NR }' ); echo $V $VAL) >> $F
  17. done
  18. if [ $I == 0 ]; then
  19. cat $F > $TMPJOIN
  20. else
  21. join $TMPJOIN $F > $OUTPUT
  22. cp $OUTPUT $TMPJOIN
  23. fi
  24. rm $F
  25. done
  26. rm $TMPJOIN
  27. gnuplot bench.gnu
  28. convert -density 200 -resize 800x560 -flatten bench.eps bench.png
  29. rm bench.eps