Permalink
Browse files

Adding some benchmarks using org-babel

  • Loading branch information...
1 parent b280dfe commit 0e120d52cdfd064a163c29820f8aebe2edce4608 @wallyqs wallyqs committed Jun 17, 2012
Showing with 370 additions and 0 deletions.
  1. +4 −0 bench/Gemfile
  2. +3 −0 bench/Gemfile_6_0
  3. +3 −0 bench/Gemfile_6_1
  4. +3 −0 bench/Gemfile_6_2
  5. +3 −0 bench/Gemfile_6_3
  6. +3 −0 bench/Gemfile_redcarpet
  7. +291 −0 bench/bench.org
  8. +19 −0 bench/parsing_redcarpet_test.rb
  9. +41 −0 bench/parsing_test.rb
View
@@ -0,0 +1,4 @@
+source :rubygems
+
+# Bench with the current version in development
+gem 'org-ruby', :path => '..'
View
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'org-ruby', '0.6.0'
View
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'org-ruby', '0.6.1'
View
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'org-ruby', '0.6.2'
View
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'org-ruby', '0.6.3'
@@ -0,0 +1,3 @@
+source :rubygems
+
+gem 'redcarpet'
View
@@ -0,0 +1,291 @@
+* OrgRuby benchmarks
+** How to run the benchmarks (or trying out org-babel)
+
+Within this folder there is a =parsing_test.rb= script which can be used
+to profile a quick benchmark of the current performance of the org-ruby library.
+
+What follows are the results of my benchmark by using the built-in support
+for org-babel included in Emacs 24. (press C-c C-c when over the block to update the benchmark)
+
+** Platform: 1.8.7
+
+For some reason performance is a bit better when using Ruby 1.8.7
+than when using 1.9.2.
+
+*** OrgRuby 0.6.0
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.8.7 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_0" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_0" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.0 with Ruby 1.8.7
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 1.820000 0.040000 1.860000 ( 1.894356)
+: ------------------------------------------ total: 1.860000sec
+:
+: user system total real
+: html conversion 1.840000 0.010000 1.850000 ( 1.878953)
+
+*** OrgRuby 0.6.2
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.8.7 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_2" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_2" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.2 with Ruby 1.8.7
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 2.060000 0.030000 2.090000 ( 2.123677)
+: ------------------------------------------ total: 2.090000sec
+:
+: user system total real
+: html conversion 2.080000 0.030000 2.110000 ( 2.135976)
+
+*** OrgRuby 0.6.3
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.8.7 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_3" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_3" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.3 with Ruby 1.8.7
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 2.060000 0.040000 2.100000 ( 2.126579)
+: ------------------------------------------ total: 2.100000sec
+:
+: user system total real
+: html conversion 2.090000 0.030000 2.120000 ( 2.139272)
+
+*** DEV
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.8.7 > /dev/null
+rvm info | grep full_version
+bundle install > /dev/null
+bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.3 with Ruby 1.8.7
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 2.050000 0.030000 2.080000 ( 2.147836)
+: ------------------------------------------ total: 2.080000sec
+:
+: user system total real
+: html conversion 2.050000 0.030000 2.080000 ( 2.102787)
+
+** Platform: 1.9.2
+
+Remember that 1.9.2 is sensible to encoding issues. (e.g. あいうえお)
+
+*** OrgRuby 0.6.0
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+export LANG=en_US.UTF-8
+rvm use 1.9.2 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_0" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_0" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.0 with Ruby 1.9.2
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 3.250000 0.020000 3.270000 ( 3.313767)
+: ------------------------------------------ total: 3.270000sec
+:
+: user system total real
+: html conversion 3.220000 0.020000 3.240000 ( 3.307011)
+
+*** OrgRuby 0.6.2
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+export LANG=en_US.UTF-8
+rvm use 1.9.2 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_2" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_2" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.2 with Ruby 1.9.2
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 3.440000 0.030000 3.470000 ( 3.529776)
+: ------------------------------------------ total: 3.470000sec
+:
+: user system total real
+: html conversion 3.440000 0.030000 3.470000 ( 3.519090)
+
+*** OrgRuby 0.6.3
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+export LANG=en_US.UTF-8
+rvm use 1.9.2 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_6_3" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_6_3" bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.3 with Ruby 1.9.2
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 3.430000 0.030000 3.460000 ( 3.526293)
+: ------------------------------------------ total: 3.460000sec
+:
+: user system total real
+: html conversion 3.440000 0.030000 3.470000 ( 3.525800)
+
+*** DEV
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+export LANG=en_US.UTF-8
+rvm use 1.9.2 > /dev/null
+rvm info | grep full_version
+bundle install > /dev/null
+bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.3 with Ruby 1.9.2
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 3.380000 0.020000 3.400000 ( 3.469689)
+: ------------------------------------------ total: 3.400000sec
+:
+: user system total real
+: html conversion 3.380000 0.030000 3.410000 ( 3.441502)
+
+** Platform: 1.9.3
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+export LANG=en_US.UTF-8
+rvm use 1.9.3 > /dev/null
+rvm info | grep full_version
+bundle install > /dev/null
+bundle exec ruby parsing_test.rb
+#+END_SRC
+
+#+RESULTS:
+: full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]"
+: Running benchmark with OrgRuby version 0.6.3 with Ruby 1.9.3
+: Parsing 30 times
+: Rehearsal ---------------------------------------------------
+: html conversion 3.810000 0.020000 3.830000 ( 3.960345)
+: ------------------------------------------ total: 3.830000sec
+:
+: user system total real
+: html conversion 3.790000 0.020000 3.810000 ( 3.848413)
+
+** Other benchmarks
+*** Similar benchmark using other markup libraries
+**** Markdown using Redcarpet in Ruby 1.8.7
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.8.7 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle exec ruby parsing_redcarpet_test.rb
+#+END_SRC
+
+#+RESULTS:
+#+begin_example
+ full_version: "ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.2.0]"
+Running benchmark with RedCarpet with Ruby 1.8.7 (n=30)
+Parsing 30 times
+Rehearsal ------------------------------------------------------------------
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.007885)
+--------------------------------------------------------- total: 0.010000sec
+
+ user system total real
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.007482)
+ 0.010000 0.000000 0.010000 ( 0.007482)
+#+end_example
+
+**** Markdown using Redcarpet in Ruby 1.9.2
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.9.2 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle exec ruby parsing_redcarpet_test.rb
+#+END_SRC
+
+#+RESULTS:
+#+begin_example
+ full_version: "ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.2.0]"
+Running benchmark with RedCarpet with Ruby 1.9.2 (n=30)
+Parsing 30 times
+Rehearsal ------------------------------------------------------------------
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.007588)
+--------------------------------------------------------- total: 0.010000sec
+
+ user system total real
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.007063)
+ 0.010000 0.000000 0.010000 ( 0.007063)
+#+end_example
+
+**** Markdown using Redcarpet in Ruby 1.9.3
+
+#+BEGIN_SRC sh :results verbatim
+source ~/.bashrc
+rvm use 1.9.3 > /dev/null
+rvm info | grep full_version
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle install > /dev/null
+BUNDLE_GEMFILE="Gemfile_redcarpet" bundle exec ruby parsing_redcarpet_test.rb
+#+END_SRC
+
+#+RESULTS:
+#+begin_example
+ full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]"
+Running benchmark with RedCarpet with Ruby 1.9.3 (n=30)
+Parsing 30 times
+Rehearsal ------------------------------------------------------------------
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.007438)
+--------------------------------------------------------- total: 0.010000sec
+
+ user system total real
+html conversion with Redcarpet 0.010000 0.000000 0.010000 ( 0.006909)
+ 0.010000 0.000000 0.010000 ( 0.006909)
+#+end_example
+
+*** TODO Encoding benchmarks
+
+**** Not setting default Encoding
+**** Setting Encoding::UTF_8 as default
+**** Setting Encoding::ASCII_8BIT as default
@@ -0,0 +1,19 @@
+require 'redcarpet'
+require 'benchmark'
+
+def run_benchmark(n=30)
+ org_content = File.open('bench.org').read
+
+ puts "Parsing #{n} times"
+ markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML)
+ Benchmark.bmbm do |x|
+ x.report('html conversion with Redcarpet') do
+ n.times do
+ markdown.render(org_content)
+ end
+ end
+ end
+end
+
+puts "Running benchmark with RedCarpet with Ruby #{RUBY_VERSION} (n=30)"
+run_benchmark
View
@@ -0,0 +1,41 @@
+require 'org-ruby'
+require 'benchmark'
+
+def run_html_output_benchmark(n=30)
+ org_content = File.open('bench.org').read
+
+ puts "Parsing #{n} times"
+ Benchmark.bmbm do |x|
+
+ x.report('html conversion') do
+ n.times do
+ Orgmode::Parser.new(org_content).to_html
+ end
+ end
+ end
+end
+
+def run_textile_output_benchmark(n=30)
+ org_content = File.open('bench.org').read
+
+ puts "Parsing #{n} times"
+ x.report('textile conversion') do
+ n.times do
+ Orgmode::Parser.new(content).to_textile
+ end
+ end
+end
+
+def run_parsing_file_benchmark(n=30)
+ puts "Parsing #{n} times"
+ x.report('textile conversion') do
+ n.times do
+ Orgmode::Parser.load('bench.org')
+ end
+ end
+end
+
+puts "Running benchmark using OrgRuby version #{OrgRuby::VERSION} with Ruby #{RUBY_VERSION}"
+run_html_output_benchmark
+# run_textile_output_benchmark
+# run_parsing_file_benchmark

0 comments on commit 0e120d5

Please sign in to comment.