Sha256: 076c9118df219d62580bb19c19746588bab31d4a6ef09551cffb8746b6d36d07

Contents?: true

Size: 1.59 KB

Versions: 7

Compression:

Stored size: 1.59 KB

Contents

$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("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("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("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

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
bert-1.1.6 bench/bench.rb
schmurfy-bert-1.2.3 bench/bench.rb
bert-1.1.2-java bench/bench.rb
schleyfox-bert-1.1.2 bench/bench.rb
bert-1.1.2 bench/bench.rb
bert-1.1.1 bench/bench.rb
bert-1.1.0 bench/bench.rb