File tree Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Expand file tree Collapse file tree 3 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -19,10 +19,11 @@ def benchmark_encoding(name, ruby_obj)
1919 puts "== Encoding #{ name } (#{ json_output . size } bytes)"
2020
2121 Benchmark . ips do |x |
22- x . report ( "yajl" ) { Yajl ::Encoder . new . encode ( ruby_obj ) } if RUN [ :yajl ]
2322 x . report ( "json" ) { JSON . dump ( ruby_obj ) } if RUN [ :json ]
23+ x . report ( "yajl" ) { Yajl ::Encoder . new . encode ( ruby_obj ) } if RUN [ :yajl ]
2424 x . report ( "oj" ) { Oj . dump ( ruby_obj ) } if RUN [ :oj ]
2525 x . report ( "rapidjson" ) { RapidJSON . encode ( ruby_obj ) } if RUN [ :rapidjson ]
26+ x . compare! ( order : :baseline )
2627 end
2728 puts
2829end
Original file line number Diff line number Diff line change @@ -19,13 +19,14 @@ def benchmark_parsing(name, json_output)
1919 puts "== Parsing #{ name } (#{ json_output . size } bytes)"
2020
2121 Benchmark . ips do |x |
22- x . report ( "yajl" ) { Yajl ::Parser . new . parse ( json_output ) } if RUN [ :yajl ]
2322 x . report ( "json" ) { JSON . parse ( json_output ) } if RUN [ :json ]
23+ x . report ( "yajl" ) { Yajl ::Parser . new . parse ( json_output ) } if RUN [ :yajl ]
2424 x . report ( "oj" ) { Oj . load ( json_output ) } if RUN [ :oj ]
2525 x . report ( "oj strict" ) { Oj . strict_load ( json_output ) } if RUN [ :oj ]
2626 x . report ( "Oj::Parser" ) { Oj ::Parser . usual . parse ( json_output ) } if RUN [ :oj ]
2727 x . report ( "fast_jsonparser" ) { FastJsonparser . parse ( json_output ) } if RUN [ :fast_jsonparser ]
2828 x . report ( "rapidjson" ) { RapidJSON . parse ( json_output ) } if RUN [ :rapidjson ]
29+ x . compare! ( order : :baseline )
2930 end
3031 puts
3132end
Original file line number Diff line number Diff line change @@ -21,6 +21,7 @@ def benchmark_parsing(name, json_output)
2121 Benchmark . ips do |x |
2222 x . report ( "parse" ) { RapidJSON . parse ( json_output ) } if RUN [ :parse ]
2323 x . report ( "validate" ) { RapidJSON . valid_json? ( json_output ) } if RUN [ :validate ]
24+ x . compare! ( order : :baseline )
2425 end
2526 puts
2627end
You can’t perform that action at this time.
0 commit comments