0

I am trying to use Ruby's standard lib profiler, and I am not using ruby-prof because this is a jruby project.

Though, I am allways getting something like:

  %   cumulative   self              self     total
 time   seconds   seconds    calls  ms/call  ms/call  name
  0.00     0.93      0.00        1     0.00   930.00  #toplevel

The code that generates this is:

require 'profiler'
Profiler__.start_profile
#  profiling_result = RubyProf.profile do
result=  handle_request

#  end
#Profiler__.stop_profile

#  printer = RubyProf::FlatPrinter.new(result)
File.open("#{File.dirname(__FILE__)}/profiler/#{Time.now.to_i}.flat","w") do |f|
  Profiler__.print_profile f
end
Profiler__.stop_profile
Machavity
  • 30,841
  • 27
  • 92
  • 100
Pedro Rolo
  • 28,273
  • 12
  • 60
  • 94

1 Answers1

2

I would strongly recommend using the JRuby built-in profiler, detailed here: http://danlucraft.com/blog/2011/03/built-in-profiler-in-jruby-1.6/

The stdlib profiler uses feature of Ruby that incur a tremendous perf hit (set_trace_func, among others). You'll get better results using the built-in profiler, which avoids such overhead.