public
Last active

CRuby benchmark scripts(http://www.callcc.net/ruby/cruby-bm/)

  • Download Gist
README.rdoc
RDoc

Requirements

  • ruby 1.9.3-p0(–prefix=/usr/local/ruby-1.9.3)

  • gnuplot

Usage

cd /tmp
git clone git://github.com/ruby/ruby.git
cd ruby
cp -a benchmark /tmp
sh path/to/bm-run.sh
^C
mkdir /tmp/dest
ruby path/to/bm-merge.rb /tmp/ruby/bmlog 10
cd /tmp/dest
sh path/to/bm-make-graph.sh
bm-make-graph.sh
Shell
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
#!/bin/sh
 
cat <<END > index.html
<html>
<haed>
<title>CRuby Benchmark</title>
</head>
<body>
<p>These graphs show how many times CRuby \${rev} is slower than 1.9.3-p0.</p>
<pre>Benchmark options:
-r 3 -v --executables="193-p0::/usr/local/ruby-1.9.3/bin/ruby ./tool/runruby.rb; 193-p0-nogems::/usr/local/ruby-1.9.3/bin/ruby ./tool/runruby.rb -- --disable-gems;r\${rev}::./ruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext --;r\${rev}-nogems::./ruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems"</pre>
END
 
for i in *.plot
do
ipng="${i%.plot}.png"
echo '<img src="'$ipng'" /><br />' >> index.html
rm src.dat
echo 'set terminal png' >> src.dat
echo 'set output "'$ipng'"' >> src.dat
echo 'set title "'${i%.plot}'"' >> src.dat
echo 'set xtics rotate by 90' >> src.dat
echo 'f(x)=1' >> src.dat
echo 'plot f(x) notitle with lines, "'$i'" using 0:6:xticlabels(1) title 6 with lines, "'$i'" using 0:7 title 7 with lines' >> src.dat
gnuplot src.dat
done
 
echo '</body></html>' >> index.html
bm-merge.rb
Ruby
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 37 38 39 40 41 42 43
# -*- coding: utf-8 -*-
 
DESTDIR='/tmp/dest'
 
dirname = ARGV.shift
x_label_every = (ARGV.shift || 30).to_i
 
def logfile_to_hash(filepath)
STDERR.puts filepath
Hash[*open(filepath, &:read).each_line.drop_while {|i| ! (/\Abenchmark results:/ =~ i) }[3..-3]\
.map {|i| bmname, *res, _ = i.chomp.split(/\t/); [bmname, res] }.flatten(1)]
end
 
target_193 = logfile_to_hash(File.join(dirname, 'bm-target-193.log'))
bm_names = target_193.keys.sort
 
# all
# {'bm_app_answer' => {rev => [gem193, nogem193, gemrev, nogemrev, gemrev/gem193, nogemrev/nogem193]}, ...}
all = Dir.glob(File.join(dirname, 'bm-[0-9]*.log')).each.with_object(Hash.new{{}}) do |logfile, obj|
rev = logfile.slice(/\d+/).to_i
begin
h = logfile_to_hash(logfile)
bm_names.each do |bmname|
o = obj[bmname]
gem193, nogem193, gemrev, nogemrev = (target_193[bmname] + h[bmname]).map(&:to_f)
o[rev] = [gem193, nogem193, gemrev, nogemrev, gemrev/gem193, nogemrev/nogem193]
obj[bmname] = o
end
rescue
end
end
 
all.each do |bmname, res|
File.open(File.join(DESTDIR, bmname + ".plot"), "w") do |f|
f.puts '"Revision" "_" "_" "_" "_" "--enable-gems" "--disable-gems"'
res.sort_by {|(rev,_)| rev}.map do |*v|
v.join(' ')
end.each_slice(x_label_every) {|(h, *rest)|
f.puts h
f.puts rest.join("\n").gsub(/^[0-9]+/,'""') unless rest.empty?
}
end
end
bm-run.sh
Shell
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 37 38 39 40
#!/bin/sh
 
[ -r bmlog ] || mkdir bmlog
 
if [ ! -r "bmlog/bm-target-193.log" ]
then
rm -rf benchmark
cp -a /tmp/benchmark benchmark
ruby benchmark/driver.rb -r 3 -v -o "bmlog/bm-target-193.log" --executables="193-p0::/usr/local/ruby-1.9.3-p0/bin/ruby ./tool/runruby.rb; 193-p0-nogems::/usr/local/ruby-1.9.3-p0/bin/ruby ./tool/runruby.rb -- --disable-gems" --pattern='bm_' --directory=./benchmark
fi
 
while :
do
rev=$(git log -1|grep -o 'trunk@[0-9]*'|cut -d@ -f 2)
 
make -j 2
if [ $? -ne 0 ]
then
git reset --hard 'HEAD~'
continue
fi
 
if [ ! -r "bmlog/bm-${rev}.log" ]
then
rm -rf benchmark
cp -a /tmp/benchmark benchmark
 
ruby benchmark/driver.rb -r 3 -v -o "bmlog/bm-${rev}.log" --executables="r${rev}::./ruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext --;r${rev}-nogems::./ruby -I./lib -I. -I.ext/common ./tool/runruby.rb --extout=.ext -- --disable-gems" --pattern='bm_' --directory=./benchmark
make clean
git reset --hard 'HEAD~15'
else
git reset --hard 'HEAD~'
fi
 
while :
do
[ "$(git log -1 --format="%an")" = "svn" ] || break
git reset --hard 'HEAD~'
done
done

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.