1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#!/usr/bin/env bash
# Usage: script/benchmark [compare|record]
set -e
task="${1:-compare}"
case "$task" in
record )
bin/rake
bin/readygo --record test/benchmark.rb
;;
compare )
bin/readygo --compare test/benchmark.rb | \
{ if [ -t 1 ]; then
# Colorize benchmark output. If performance is negatively affected
# compared to baseline, highlight the "Current" line in red.
ruby -pe '
case $_
when /Baseline:/ then baseline = $_.index("X")
when /Current:/
$_ = "\e[%dm%s\e[m" % [ $_.index("X") > baseline ? 31 : 32, $_ ]
end
'
else
cat
fi
}
;;
-h | --help )
sed -ne '/^#/!q;s/.\{1,2\}//;1d;p' < "$0"
exit 0
;;
* )
"$0" --help >&2
exit 1
esac
|