This repository is private.
All pages are served over SSL and all pushing and pulling is done over SSH.
No one may fork, clone, or view it unless they are added as a member.
Every repository with this icon (
) is private.
Every repository with this icon (
This repository is public.
Anyone may fork, clone, or view it.
Every repository with this icon (
) is public.
Every repository with this icon (
Run the following if you haven't already:
gem sources -a http://gems.github.com
Install the gem(s):
sudo gem install somebee-rbench
commit eb131040780155fabf99d650d67260e340672f3d
tree 5b12e0e23a7f700d5f72dc0e946921ad938a0435
parent a1c88474920fdf3bf9b3629fc3973de6e1166364
tree 5b12e0e23a7f700d5f72dc0e946921ad938a0435
parent a1c88474920fdf3bf9b3629fc3973de6e1166364
rbench /
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Jun 15 15:24:59 -0700 2008 | |
| |
LICENSE | Sun Jun 15 15:47:32 -0700 2008 | |
| |
README | Sun Jun 15 15:27:23 -0700 2008 | |
| |
Rakefile | Sun Jun 15 15:24:59 -0700 2008 | |
| |
TODO | Sun Jun 15 15:24:59 -0700 2008 | |
| |
lib/ | Tue Jun 17 04:15:42 -0700 2008 | |
| |
rbench.gemspec | Mon Jun 16 09:39:04 -0700 2008 | |
| |
spec/ | Mon Jun 16 09:39:04 -0700 2008 |
rbench
======
== What is RBench?
Library for generating nice ruby-benchmarks in several formats.
Only text-output is available atm.
Heavily inspired by benchwarmer. Much love.
== Usage
require "rubygems"
require "rbench"
# Choose how many times you want to repeat each benchmark.
# This can be overridden on specific reports, if needed.
TIMES = 100_000
# A relatively simple benchmark:
RBench.run(TIMES) do
column :one
column :two
report "Squeezing with #squeeze" do
one { "abc//def//ghi//jkl".squeeze("/") }
two { "abc///def///ghi///jkl".squeeze("/") }
end
report "Squeezing with #gsub" do
one { "abc//def//ghi//jkl".gsub(/\/+/, "/") }
two { "abc///def///ghi///jkl".gsub(/\/+/, "/") }
end
report "Splitting with #split" do
one { "aaa/aaa/aaa.bbb.ccc.ddd".split(".") }
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".split(".") }
end
report "Splitting with #match" do
one { "aaa/aaa/aaa.bbb.ccc.ddd".match(/\.([^\.]*)$/) }
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".match(/\.([^\.]*)$/) }
end
end
# The benchmark above will output the following:
ONE | TWO |
--------------------------------------------------------------------------------
Squeezing with #squeeze 0.122 | 0.118 |
Squeezing with #gsub 0.274 | 0.271 |
Splitting with #split 0.349 | 0.394 |
Splitting with #match 0.238 | 0.291 |
# Now onto a benchmark that utilizes a some more stiff.
RBench.run(TIMES) do
format :width => 65
column :times
column :one, :title => "#1"
column :two, :title => "#2"
column :diff, :title => "#1/#2", :compare => [:one,:two]
group "Squeezing" do
report "with #squeeze" do
one { "abc//def//ghi//jkl".squeeze("/") }
two { "abc///def///ghi///jkl".squeeze("/") }
end
report "with #gsub" do
one { "abc//def//ghi//jkl".gsub(/\/+/, "/") }
two { "abc///def///ghi///jkl".gsub(/\/+/, "/") }
end
summary "all methods (totals)"
end
group "Splitting" do
report "with #split" do
one { "aaa/aaa/aaa.bbb.ccc.ddd".split(".") }
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".split(".") }
end
report "with #match", TIMES / 100 do
one { "aaa/aaa/aaa.bbb.ccc.ddd".match(/\.([^\.]*)$/) }
two { "aaa//aaa//aaa.bbb.ccc.ddd.eee".match(/\.([^\.]*)$/) }
end
end
end
# The benchmark above will output the following:
| #1 | #2 | #1/#2 |
--Squeezing------------------------------------------------------
with #squeeze x100000 | 0.122 | 0.117 | 1.04x |
with #gsub x100000 | 0.267 | 0.279 | 0.96x |
all methods (totals) | 0.390 | 0.396 | 0.98x |
--Splitting------------------------------------------------------
with #split x100000 | 0.341 | 0.394 | 0.87x |
with #match x1000 | 0.002 | 0.003 | 0.82x |











