如何使用perftools和bundler来分析RSpec?

Dmy*_*iak 16 ruby profiling rspec ruby-on-rails google-perftools

我需要分析我经常运行的测试套件bundle exec rspec spec/并生成GIF图像.

运行perftools.rb以使其与bundler一起正常工作的命令是什么?

kat*_*tan 16

我也不得不四处寻找.这就是我做的

  1. 把它放在spec_helper.rb中:

    config.before :suite do
      PerfTools::CpuProfiler.start("/tmp/rspec_profile")
    end
    
    config.after :suite do
      PerfTools::CpuProfiler.stop
    end
    
    Run Code Online (Sandbox Code Playgroud)
  2. 运行你的rspec

  3. 运行pprof来获取您的号码

    pprof.rb --text  /tmp/rspec_profile
    
    Run Code Online (Sandbox Code Playgroud)