6
Rails中是否有類似於Ruby Benchmark的東西?過去我使用過Ruby基準來比較不同的代碼,但沒有一個與Rails相關。我想用我的應用模式在一些基準測試做線沿線的東西...Benchmarking Rails模型方法
#!/usr/bin/ruby
require 'benchmark'
Benchmark.bmbm do |x|
x.report("Benchmark 1") do
1_000_000.times do
# do something here...
end
end
x.report("Benchmark 2") do
1_000_000.times do
# Do something else here...
end
end
end
,給了我這樣的一些輸出:
Rehearsal -----------------------------------------------
Benchmark 1 0.070000 0.000000 0.070000 ( 0.069236)
Benchmark 2 0.070000 0.000000 0.070000 ( 0.069227)
-------------------------------------- total: 0.140000sec
user system total real
Benchmark 1 0.070000 0.000000 0.070000 ( 0.069793)
Benchmark 2 0.070000 0.000000 0.070000 ( 0.069203)
我看着腳本/性能/基準測試人員和腳本/性能/分析器,但我無法找出比較方法的方法。我也考慮過在測試中做這件事,但我沒有任何斷言,所以這似乎沒有道理。
感謝您的鏈接。 – 2010-02-20 18:41:11