Rails中有没有类似于Ruby基准测试的东西?我曾经使用过Ruby基准测试来比较不同的代码,但没有一个是与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-21 01:02:25
Performance testing your rails application可能就是您所需要的。我认为这就是你对独立Rails所能做的一切。
https://stackoverflow.com/questions/2302754
复制相似问题