Class: FFI_Yajl::Benchmark::ParseProfile

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi_yajl/benchmark/parse_profile.rb

Instance Method Summary collapse

Instance Method Details

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ffi_yajl/benchmark/parse_profile.rb', line 18

def run
  if defined?(PerfTools)
    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"

    PerfTools::CpuProfiler.start("/tmp/ffi_yajl_encode_profile.out") do
      times.times {
        output = FFI_Yajl::Parser.parse(json)
      }
    end
    system("pprof.rb --text /tmp/ffi_yajl_encode_profile.out")
  end
end