summaryrefslogtreecommitdiff
path: root/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ffi_yajl/benchmark/parse_json_and_yaml.rb')
-rw-r--r--lib/ffi_yajl/benchmark/parse_json_and_yaml.rb34
1 files changed, 17 insertions, 17 deletions
diff --git a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
index 5076f67..6e479ce 100644
--- a/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
+++ b/lib/ffi_yajl/benchmark/parse_json_and_yaml.rb
@@ -16,26 +16,26 @@ json = File.new(filename, 'r')
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|
+Benchmark.bmbm do |x|
parser = Yajl::Parser.new
- parser.on_parse_complete = lambda { |obj| } if times > 1
- x.report {
+ parser.on_parse_complete = ->(obj) {} if times > 1
+ x.report do
puts "Yajl::Parser#parse"
- times.times {
+ times.times do
json.rewind
parser.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
-}
+end
json.close
# YAML section
@@ -43,13 +43,13 @@ filename = 'benchmark/subjects/ohai.yml'
yaml = File.new(filename, 'r')
puts "Starting benchmark parsing #{File.size(filename)} bytes of YAML data #{times} times\n\n"
-Benchmark.bmbm { |x|
- x.report {
+Benchmark.bmbm do |x|
+ x.report do
puts "YAML.load_stream"
- times.times {
+ times.times do
yaml.rewind
YAML.load(yaml)
- }
- }
-}
+ end
+ end
+end
yaml.close