2013-02-17 62 views
6

我創建了一個分析和存儲數據的重腳本,我真的需要知道大部分時間我的代碼中哪些行消耗了。 Rubymine是否具有配置文件功能,或者有可能以某種方式向它添加配置文件?ruby​​中的剖析器

回答

2

我也在尋找它,但沒有成功。如果你發現了什麼,請告訴我。

同時...在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 

,它會給你好看分析結果表

   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) 

Profiler__http://apidock.com/ruby/Profiler__

使用這個模塊最簡單的方法就是require 'profile'和你的腳本完成後,吹出來的數據每通電話的。

檢查本例http://ruby.about.com/od/advancedruby/a/profile.htm