* 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
