[英]Benchmarking Rails Model Methods
在Rails中有类似于Ruby Benchmark的东西吗? 我过去曾使用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)
我查看了脚本/性能/基准测试程序和脚本/性能/分析器,但我无法找到比较方法的方法。 我也考虑过在测试中做这件事,但我没有任何断言,所以这似乎没有意义。
您可能只需要对rails应用程序进行性能测试 。 我认为这就是你可以用独立的Rails做的一切。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.