-
Notifications
You must be signed in to change notification settings - Fork 1
Home
keita edited this page Sep 12, 2010
·
5 revisions
Home.ja (日本語)
BenchmarkX is standard benchmark with sexy graph using Gruff.
% sudo gem install
BenchmarkX behaves almost same as standard Benchmark module(benchmark.rb).
require "benchmarkx"
BenchmarkX.bm |x| do
# set the graph's filename
x.filename = "graph.png"
# set the graph's title
x.gruff.title = "#{n} times iterations of `a = \"1\"'"
x.report("for:") {for i in 1..n; a = "1"; end} # Benchmark::measure
x.report("times:") {n.times do ; a = "1"; end}
x.report("upto:") {1.upto(n) do ; a = "1"; end}
end
This benchmark makes the following graph:
And also output standard benchmark result to STDOUT.
50000 times iterations of `a = "1"'
user system total real
for: 0.040000 0.010000 0.050000 ( 0.062325)
times: 0.030000 0.000000 0.030000 ( 0.049322)
upto: 0.050000 0.010000 0.060000 ( 0.065992)
- Gruff
- BenchmarkX