diff options
Diffstat (limited to 'lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb')
-rw-r--r-- | lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb index f71a756..51696c5 100644 --- a/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb +++ b/lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb @@ -14,23 +14,20 @@ module FFI_Yajl puts "INFO: perftools.rb gem not installed" end - if defined?(RubyProf) - filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) - json = File.new(filename, 'r').read + return if defined?(RubyProf) - times = 1000 - puts "Starting profiling encoding #{filename} #{times} times\n\n" + filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) + json = File.new(filename, 'r').read - result = RubyProf.profile do - times.times { - FFI_Yajl::Parser.parse(json) - } - end - - printer = RubyProf::GraphPrinter.new(result) - printer.print(STDOUT, {}) + times = 1000 + puts "Starting profiling encoding #{filename} #{times} times\n\n" + result = RubyProf.profile do + times.times { FFI_Yajl::Parser.parse(json) } end + + printer = RubyProf::GraphPrinter.new(result) + printer.print(STDOUT, {}) end end end |