简体   繁体   English

如何在Jruby中使用Ruby stdlib profiler?

[英]How to use the Ruby stdlib profiler with Jruby?

I am trying to use Ruby's standard lib profiler, and I am not using ruby-prof because this is a jruby project. 我正在尝试使用Ruby的标准lib分析器,而我不使用ruby-prof,因为这是一个jruby项目。

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

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/ 我强烈建议使用JRuby内置的分析器,详细信息请参见: 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). stdlib探查器使用Ruby的特性,可以产生巨大的性能(set_trace_func等)。 You'll get better results using the built-in profiler, which avoids such overhead. 使用内置的分析器可以获得更好的结果,从而避免了这种开销。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM