add benchmark runner and results

This commit is contained in:
Tom Preston-Werner 2009-10-24 00:49:44 -07:00
Родитель 4150346547
Коммит 1fc17e94f5
2 изменённых файлов: 68 добавлений и 0 удалений

33
bench/bench.rb Normal file
Просмотреть файл

@ -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
bench/results.txt Normal file
Просмотреть файл

@ -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)