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