sil*_*der 6 performance profiling ruby-on-rails rubymine
我创建了大量的脚本来分析和存储数据,我真的需要知道我的代码中哪些行消耗大部分时间.Rubymine是否具有探查器功能,或者可能以某种方式添加探查器?
我也在寻找它,但没有成功。如果您发现了什么,请告诉我。
同时......Ruby本身有两个模块可以帮助你
基准– http://apidock.com/ruby/Benchmark
你做这样的事情
require 'benchmark'
n = 50000
Benchmark.bm(7) do |x|
x.report("for:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1"; end }
x.report("upto:") { 1.upto(n) do ; a = "1"; end }
end
Run Code Online (Sandbox Code Playgroud)
它会给你一个很好的分析结果表
user system total real
for: 1.050000 0.000000 1.050000 ( 0.503462)
times: 1.533333 0.016667 1.550000 ( 0.735473)
upto: 1.500000 0.016667 1.516667 ( 0.711239)
Run Code Online (Sandbox Code Playgroud)
Profiler__ – http://apidock.com/ruby/Profiler__
使用此模块的最简单方法就是require 'profile'在脚本完成后,它会输出有关每个调用的数据。
检查此示例http://ruby.about.com/od/advancedruby/a/profile.htm
| 归档时间: |
|
| 查看次数: |
2118 次 |
| 最近记录: |