Skip to content

Commit

Permalink
add benchmark runner and results
Browse files Browse the repository at this point in the history
  • Loading branch information
mojombo committed Oct 24, 2009
1 parent 4150346 commit 1fc17e9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
33 changes: 33 additions & 0 deletions bench/bench.rb
@@ -0,0 +1,33 @@
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))

require 'rubygems'
require 'bert'
require 'json'
require 'yajl'
require 'benchmark'

ITER = 1_000

tiny = t[:ok, :awesome]
small = t[:ok, :answers, [42] * 42]
large = ["abc" * 1000] * 100
complex = [42, {:foo => 'bac' * 100}, t[(1..100).to_a]] * 10

Benchmark.bm do |bench|
bench.report("JSON tiny") {ITER.times {JSON.load(JSON.dump(tiny))}}
bench.report("JSON small") {ITER.times {JSON.load(JSON.dump(small))}}
bench.report("JSON large") {ITER.times {JSON.load(JSON.dump(large))}}
bench.report("JSON complex") {ITER.times {JSON.load(JSON.dump(complex))}}
bench.report("YAJL tiny") {ITER.times {Yajl::Parser.parse(Yajl::Encoder.encode(tiny))}}
bench.report("YAJL small") {ITER.times {Yajl::Parser.parse(Yajl::Encoder.encode(small))}}
bench.report("YAJL large") {ITER.times {Yajl::Parser.parse(Yajl::Encoder.encode(large))}}
bench.report("YAJL complex") {ITER.times {Yajl::Parser.parse(Yajl::Encoder.encode(complex))}}
bench.report("BERT tiny") {ITER.times {BERT.decode(BERT.encode(tiny))}}
bench.report("BERT small") {ITER.times {BERT.decode(BERT.encode(small))}}
bench.report("BERT large") {ITER.times {BERT.decode(BERT.encode(large))}}
bench.report("BERT complex") {ITER.times {BERT.decode(BERT.encode(complex))}}
bench.report("Ruby tiny") {ITER.times {Marshal.load(Marshal.dump(tiny))}}
bench.report("Ruby small") {ITER.times {Marshal.load(Marshal.dump(small))}}
bench.report("Ruby large") {ITER.times {Marshal.load(Marshal.dump(large))}}
bench.report("Ruby complex") {ITER.times {Marshal.load(Marshal.dump(complex))}}
end
35 changes: 35 additions & 0 deletions bench/results.txt
@@ -0,0 +1,35 @@
user system total real

Comparisons

JSON tiny 0.020000 0.000000 0.020000 ( 0.017486)
JSON small 0.070000 0.000000 0.070000 ( 0.080681)
JSON large 15.260000 0.600000 15.860000 ( 16.427857)
JSON complex 1.470000 0.010000 1.480000 ( 1.558230)

YAJL tiny 0.010000 0.000000 0.010000 ( 0.015537)
YAJL small 0.050000 0.000000 0.050000 ( 0.061879)
YAJL large 3.610000 0.800000 4.410000 ( 4.675255)
YAJL complex 1.030000 0.000000 1.030000 ( 1.066871)

Ruby tiny 0.010000 0.000000 0.010000 ( 0.007117)
Ruby small 0.020000 0.000000 0.020000 ( 0.015964)
Ruby large 0.040000 0.000000 0.040000 ( 0.042695)
Ruby complex 0.040000 0.000000 0.040000 ( 0.048395)

Ruby encoder / Ruby decoder
41503465479e8762916d6997d91639f0d7308a13

BERT tiny 0.090000 0.000000 0.090000 ( 0.092357)
BERT small 0.830000 0.000000 0.830000 ( 0.853270)
BERT large 4.190000 0.620000 4.810000 ( 4.959149)
BERT complex 19.380000 0.080000 19.460000 ( 20.402862)

Simple C encoder / Ruby decoder
41503465479e8762916d6997d91639f0d7308a13

BERT tiny 0.030000 0.000000 0.030000 ( 0.033826)
BERT small 0.390000 0.010000 0.400000 ( 0.413229)
BERT large 2.270000 0.550000 2.820000 ( 3.029141)
BERT complex 8.680000 0.040000 8.720000 ( 9.097990)

0 comments on commit 1fc17e9

Please sign in to comment.