Skip to content

Commit

Permalink
Update benchmarking facility to allow benchmarking relative Ruby perf…
Browse files Browse the repository at this point in the history
…ormance
  • Loading branch information
gettalong committed Dec 26, 2020
1 parent 84e305c commit a7bd1f3
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 5 deletions.
14 changes: 14 additions & 0 deletions benchmark/benchmark-rubies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash --login

./benchmark/benchmark.sh -k master -r "$@" -a 3

eval $(grep -e '^TMPDIR' benchmark/benchmark.sh)
cd $TMPDIR

for I in kramdown-ruby*.dat; do
echo $I | sed -E 's/.*(ruby-.*p[0-9]+(-jit)?).*/\1 ||/' > $I.ruby
awk '{ print $2 }' $I | tail -n +2 >> $I.ruby
done
paste <(awk '{ print $1 }' $(ls kramdown-ruby*.dat | head -n 1)) *.ruby > kramdown-rubies.dat

ruby generate_data.rb -g
11 changes: 9 additions & 2 deletions benchmark/benchmark.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,15 @@ git clone .git ${TMPDIR}/kramdown
cd ${TMPDIR}/kramdown

for RUBY_VERSION in $RUBY_VERSIONS; do
rbenv shell $RUBY_VERSION
echo "Creating benchmark data for $(ruby -v)"
if [[ ${RUBY_VERSION: -1} = j ]]; then
rbenv shell ${RUBY_VERSION%j}
export RUBYOPT=--jit
else
rbenv shell $RUBY_VERSION
unset RUBYOPT
fi

echo "Creating benchmark data for $(ruby -v) and RUBYOPT=${RUBYOPT}"

for KD_VERSION in $KD_VERSIONS; do
echo "Using kramdown version $KD_VERSION"
Expand Down
8 changes: 5 additions & 3 deletions benchmark/generate_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@
opts.on("-k VERSION", "--kramdown VERSION", String, "Add benchmark data for kramdown version VERSION") {|v| options[:kramdown] = v}
end.parse!

THISRUBY = (self.class.const_defined?(:RUBY_DESCRIPTION) ? RUBY_DESCRIPTION.scan(/^.*?(?=\s*\(|,)/).first.sub(/\s/, '-') : "ruby-#{RUBY_VERSION}") + '-' + RUBY_PATCHLEVEL.to_s
THISRUBY = (self.class.const_defined?(:RUBY_DESCRIPTION) ? RUBY_DESCRIPTION.scan(/^.*?(?=\s*\(|,)/).first.sub(/\s/, '-') : "ruby-#{RUBY_VERSION}")
THISRUBY << '-' + RUBY_PATCHLEVEL.to_s unless THISRUBY =~ /p#{RUBY_PATCHLEVEL}$/
THISRUBY << '-jit' if RUBY_DESCRIPTION =~ /JIT/

Dir.chdir(File.dirname(__FILE__))
BMDATA = File.read('mdbasics.text')
MULTIPLIER = (0..5).map {|i| 2**i}
MULTIPLIER = (8..10).map {|i| 2**i}

if options[:others]
require 'maruku'
Expand Down Expand Up @@ -84,7 +86,7 @@ def tell_user(s)
end
end
end
times.each_with_index {|t,i| data[i+1] << "%14.5f" % (t.inject(0) {|sum,v| sum+v}/3.0)}
times.each_with_index {|t,i| data[i+1] << "%14.5f" % (t.inject(0) {|sum,v| sum+v}/t.size)}
File.open(kramdown, 'w+') do |f|
data.each {|l| f.puts l}
end
Expand Down

0 comments on commit a7bd1f3

Please sign in to comment.