class FFI_Yajl::Benchmark::ParseProfileRubyProf

Public Instance Methods

run() click to toggle source
# File lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb, line 11
def run
  begin
    require 'ruby-prof'
  rescue Exception
    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

    times = 1000
    puts "Starting profiling encoding #{filename} #{times} times\n\n"

    result = RubyProf.profile do
      times.times {
        output = FFI_Yajl::Parser.parse(json)
      }
    end

    printer = RubyProf::GraphPrinter.new(result)
    printer.print(STDOUT, {})

  end
end