summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi_yajl/benchmark/parse_json_and_marshal.rb')
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_marshal.rb30
1 files changed, 15 insertions, 15 deletions
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
index 204ab06..cd07d46 100644
--- a/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
+++ b/lib/ffi_yajl/benchmark/parse_json_and_marshal.rb
@@ -19,32 +19,32 @@ hash = {}
times = ARGV[0] ? ARGV[0].to_i : 1000
puts "Starting benchmark parsing #{File.size(filename)} bytes of JSON data #{times} times\n\n"
-Benchmark.bmbm { |x|
- x.report {
+Benchmark.bmbm do |x|
+ x.report do
puts "Yajl::Parser#parse"
yajl = Yajl::Parser.new
- yajl.on_parse_complete = lambda { |obj| } if times > 1
- times.times {
+ yajl.on_parse_complete = ->(obj) {} if times > 1
+ times.times do
json.rewind
hash = yajl.parse(json)
- }
- }
+ end
+ end
if defined?(JSON)
- x.report {
+ x.report do
puts "JSON.parse"
- times.times {
+ times.times do
json.rewind
JSON.parse(json.read, max_nesting: false)
- }
- }
+ end
+ end
end
- x.report {
+ x.report do
puts "Marshal.load"
- times.times {
+ times.times do
marshal_file.rewind
Marshal.load(marshal_file)
- }
- }
-}
+ end
+ end
+end
json.close
marshal_file.close