Sha256: beb34f2e2c880d0b492c2e43869371f174553c87806cdc1ad11ae7b6ca62959f
Contents?: true
Size: 996 Bytes
Versions: 9
Compression:
Stored size: 996 Bytes
Contents
# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario # See MIT-LICENSE require "rubygems" unless defined?(Gem) require_relative "../../ffi_yajl" begin require "perftools" rescue LoadError puts "INFO: perftools.rb gem not installed" end ENV["CPUPROFILE_FREQUENCY"] = "4000" module FFI_Yajl class Benchmark class EncodeProfile def run return unless defined?(PerfTools) filename = File.expand_path(File.join(File.dirname(__FILE__), "subjects", "ohai.json")) hash = File.open(filename, "rb") { |f| FFI_Yajl::Parser.parse(f.read) } times = 1000 puts "Starting profiling encoding #{filename} #{times} times\n\n" ffi_string_encoder = FFI_Yajl::Encoder.new PerfTools::CpuProfiler.start("/tmp/ffi_yajl_encode_profile.out") do times.times { ffi_string_encoder.encode(hash) } end system("pprof.rb --text /tmp/ffi_yajl_encode_profile.out") end end end end
Version data entries
9 entries across 9 versions & 1 rubygems