Skip to content

Instantly share code, notes, and snippets.

@blambeau
Created August 26, 2011 07:58
Show Gist options
  • Save blambeau/1172939 to your computer and use it in GitHub Desktop.
Save blambeau/1172939 to your computer and use it in GitHub Desktop.
Sloppy and tidy in Viiite
# A benchmark pioneered by @tenderlove
# @see https://gist.github.com/1170106
class Sloppy
def sloppy; @sloppy; end
end
class Tidy
def initialize; @tidy = nil; end
def tidy; @tidy; end
end
require 'viiite'
n = 100_000_000
Viiite.bm do |b|
tidy = Tidy.new
sloppy = Sloppy.new
b.variation_point :ruby, Viiite.which_ruby
b.report(:tidy) { n.times{ tidy.tidy } }
b.report(:sloppy) { n.times{ sloppy.sloppy } }
end
$ rvm exec viiite --append run --runs=10 sloppy_and_tidy
...
$ viiite report --regroup=bench,ruby --hierarchy --stddev --ff="%10.6f"
+---------+----------------------------------------------------------------------------------------+
| :bench | :measure |
+---------+----------------------------------------------------------------------------------------+
| :sloppy | +-------------------+------------+------------+------------+------------+------------+ |
| | | :ruby | :user | :system | :total | :real | :stddev | |
| | +-------------------+------------+------------+------------+------------+------------+ |
| | | jruby 1.6.3 | 19.844100 | 0.000000 | 19.844100 | 19.844100 | 0.210988 | |
| | | rubinius 1.2.5dev | 8.580536 | 0.006400 | 8.586937 | 8.592304 | 0.206369 | |
| | | rubinius 2.0.0dev | 7.834090 | 0.005600 | 7.839690 | 7.846725 | 0.034818 | |
| | | ruby 1.8.7p352 | 34.353000 | 0.015000 | 34.368000 | 34.395148 | 0.062097 | |
| | | ruby 1.9.2p290 | 22.478000 | 0.009000 | 22.487000 | 22.483678 | 0.089672 | |
| | | ruby 1.9.3dev | 18.030000 | 0.004000 | 18.034000 | 18.047614 | 0.118169 | |
| | +-------------------+------------+------------+------------+------------+------------+ |
| :tidy | +-------------------+------------+------------+------------+------------+------------+ |
| | | :ruby | :user | :system | :total | :real | :stddev | |
| | +-------------------+------------+------------+------------+------------+------------+ |
| | | jruby 1.6.3 | 19.766700 | 0.000000 | 19.766700 | 19.766700 | 0.501114 | |
| | | rubinius 1.2.5dev | 8.992562 | 0.004400 | 8.996962 | 8.863138 | 1.244846 | |
| | | rubinius 2.0.0dev | 15.222951 | 0.012001 | 15.234952 | 15.202893 | 0.740747 | |
| | | ruby 1.8.7p352 | 32.321000 | 0.023000 | 32.344000 | 32.369553 | 0.222809 | |
| | | ruby 1.9.2p290 | 15.936000 | 0.009000 | 15.945000 | 15.938642 | 0.164393 | |
| | | ruby 1.9.3dev | 14.730000 | 0.003000 | 14.733000 | 14.745098 | 0.085094 | |
| | +-------------------+------------+------------+------------+------------+------------+ |
+---------+----------------------------------------------------------------------------------------+
$ viiite report --regroup=ruby,bench --hierarchy --stddev --ff="%10.6f"
+-------------------+------------------------------------------------------------------------------+
| :ruby | :measure |
+-------------------+------------------------------------------------------------------------------+
| jruby 1.6.3 | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 19.844100 | 0.000000 | 19.844100 | 19.844100 | 0.210988 | |
| | | :tidy | 19.766700 | 0.000000 | 19.766700 | 19.766700 | 0.501114 | |
| | +---------+------------+------------+------------+------------+------------+ |
| rubinius 1.2.5dev | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 8.580536 | 0.006400 | 8.586937 | 8.592304 | 0.206369 | |
| | | :tidy | 8.992562 | 0.004400 | 8.996962 | 8.863138 | 1.244846 | |
| | +---------+------------+------------+------------+------------+------------+ |
| rubinius 2.0.0dev | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 7.834090 | 0.005600 | 7.839690 | 7.846725 | 0.034818 | |
| | | :tidy | 15.222951 | 0.012001 | 15.234952 | 15.202893 | 0.740747 | |
| | +---------+------------+------------+------------+------------+------------+ |
| ruby 1.8.7p352 | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 34.353000 | 0.015000 | 34.368000 | 34.395148 | 0.062097 | |
| | | :tidy | 32.321000 | 0.023000 | 32.344000 | 32.369553 | 0.222809 | |
| | +---------+------------+------------+------------+------------+------------+ |
| ruby 1.9.2p290 | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 22.478000 | 0.009000 | 22.487000 | 22.483678 | 0.089672 | |
| | | :tidy | 15.936000 | 0.009000 | 15.945000 | 15.938642 | 0.164393 | |
| | +---------+------------+------------+------------+------------+------------+ |
| ruby 1.9.3dev | +---------+------------+------------+------------+------------+------------+ |
| | | :bench | :user | :system | :total | :real | :stddev | |
| | +---------+------------+------------+------------+------------+------------+ |
| | | :sloppy | 18.030000 | 0.004000 | 18.034000 | 18.047614 | 0.118169 | |
| | | :tidy | 14.730000 | 0.003000 | 14.733000 | 14.745098 | 0.085094 | |
| | +---------+------------+------------+------------+------------+------------+ |
+-------------------+------------------------------------------------------------------------------+
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment