Sha256: 48727cfdc1d644105efd7d8cf71d2e32f7d7f9b77f8f4918487ac753063ee21d

Contents?: true

Size: 1015 Bytes

Versions: 50

Compression:

Stored size: 1015 Bytes

Contents

# Portions Originally Copyright (c) 2008-2011 Brian Lopez - http://github.com/brianmario
# See MIT-LICENSE

require 'rubygems'
require 'ffi_yajl'
begin
  require 'perftools'
rescue Exception
  puts "INFO: perftools.rb gem not installed"
end

ENV['CPUPROFILE_FREQUENCY'] = "4000"

module FFI_Yajl
  class Benchmark
    class EncodeProfile

      def run
        if 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 {
              output = ffi_string_encoder.encode(hash)
            }
          end
          system("pprof.rb --text /tmp/ffi_yajl_encode_profile.out")
        end
      end

    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
ffi-yajl-2.2.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-2.2.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-2.1.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-2.1.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-2.0.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-2.0.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.4.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.4.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.3.1-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.3.1 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.3.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.3.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.2.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.2.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.1.0-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.1.0 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.0.2-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.0.2 lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.0.1-universal-java lib/ffi_yajl/benchmark/encode_profile.rb
ffi-yajl-1.0.1 lib/ffi_yajl/benchmark/encode_profile.rb