繁体   English   中英

如何在Jruby中使用Ruby stdlib profiler?

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

我正在尝试使用Ruby的标准lib分析器,而我不使用ruby-prof,因为这是一个jruby项目。

虽然,我总是得到这样的东西:

  %   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

生成它的代码是:

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

我强烈建议使用JRuby内置的分析器,详细信息请参见: http//danlucraft.com/blog/2011/03/built-in-profiler-in-jruby-1.6/

stdlib探查器使用Ruby的特性,可以产生巨大的性能(set_trace_func等)。 使用内置的分析器可以获得更好的结果,从而避免了这种开销。

暂无
暂无

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

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