Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Rails模型的基准测试方法_Ruby On Rails_Ruby_Benchmarking - Fatal编程技术网

Ruby on rails Rails模型的基准测试方法

Ruby on rails Rails模型的基准测试方法,ruby-on-rails,ruby,benchmarking,Ruby On Rails,Ruby,Benchmarking,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.r

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)
我研究了script/performance/benchmarker和script/performance/profiler,但我找不出一种比较方法的方法。我也曾在测试中考虑过这样做,但我没有任何类型的断言,因此这似乎没有意义。

可能就是您所需要的。我认为这就是独立Rails所能做的