Sha256: dadc77c6289de9e739f8939302512a289bb89594ea14884a9050a52419cb8dd4

Contents?: true

Size: 893 Bytes

Versions: 9

Compression:

Stored size: 893 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"

module FFI_Yajl
  class Benchmark
    class ParseProfileRubyProf
      def run
        begin
          require "ruby-prof"
        rescue LoadError
          puts "INFO: perftools.rb gem not installed"
        end

        return 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 { FFI_Yajl::Parser.parse(json) }
        end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
ffi-yajl-2.6.0-universal-java lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.6.0 lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-3.0.0-universal-java lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-3.0.0 lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.5.0-universal-java lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.4.0-universal-java lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.4.0 lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.3.4 lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb
ffi-yajl-2.3.4-universal-java lib/ffi_yajl/benchmark/parse_profile_ruby_prof.rb