-
Notifications
You must be signed in to change notification settings - Fork 32
/
alt_bench.rb
46 lines (34 loc) · 1.04 KB
/
alt_bench.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# coding: utf-8
require 'benchmark/ips'
require 'json'
require File.expand_path('lib/jrjackson')
obj = {
:name => "Fredrick Smith",
:quantity => 1_000_000,
:addresses => {
:address1 => "12 Heather Street, Parnell, Auckland, New Zealand",
:address2 => "1 Queen Street, CBD, Auckland, New Zealand"
}
}
json = JSON.dump(obj)
puts "Decode ====================="
puts 'Sleeping'
sleep 45
puts 'Working'
# -JXrunhprof:cpu=samples,depth=30,file=jrjackson.hprof
Benchmark.ips do |x|
x.config(time: 20, warmup: 20)
x.report("JrJackson new Ruby") { JrJackson::Ruby.parse(json, nil) }
# x.report("JrJackson Raw") { JrJackson::Java.parse(json, nil) }
# x.report("JSON") { JSON.load(json) }
# x.report("JrJackson") { JrJackson::Raw.parse_sym(json) }
# x.compare!
end
# puts "Encode ====================="
# Benchmark.ips do |x|
# x.config(time: 5, warmup: 10)
# x.report("JrJackson Raw") { JrJackson::Base.generate(obj) }
# x.report("JrJackson") { JrJackson::Json.dump(obj) }
# x.report("JSON") { JSON.dump(obj) }
# x.compare!
# end