Created
October 22, 2009 15:46
-
-
Save defunkt/216030 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
user system total real | |
JSON tiny 0.010000 0.000000 0.010000 ( 0.026258) | |
JSON small 0.060000 0.000000 0.060000 ( 0.065894) | |
JSON large 11.430000 0.150000 11.580000 ( 11.907260) | |
JSON complex 1.070000 0.010000 1.080000 ( 1.101532) | |
YAJL tiny 0.000000 0.000000 0.000000 ( 0.014308) | |
YAJL small 0.040000 0.000000 0.040000 ( 0.033982) | |
YAJL large 2.820000 0.090000 2.910000 ( 2.925373) | |
YAJL complex 0.710000 0.020000 0.730000 ( 0.738953) | |
BERT tiny 0.040000 0.000000 0.040000 ( 0.040453) | |
BERT small 0.430000 0.000000 0.430000 ( 0.445005) | |
BERT large 1.990000 0.040000 2.030000 ( 2.074487) | |
BERT complex 9.340000 0.050000 9.390000 ( 9.489408) | |
Ruby tiny 0.010000 0.000000 0.010000 ( 0.006407) | |
Ruby small 0.010000 0.000000 0.010000 ( 0.011136) | |
Ruby large 0.020000 0.000000 0.020000 ( 0.024423) | |
Ruby complex 0.030000 0.010000 0.040000 ( 0.030559) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment