如何使用 perftools 和 bundler 分析 RSpec? [英] How to profile RSpec with perftools and bundler?

查看:60
本文介绍了如何使用 perftools 和 bundler 分析 RSpec?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I need to profile the test suite that I usually run with bundle exec rspec spec/ and produce the GIF image.

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

What is the command to run the perftools.rb so that it works correctly with bundler?

推荐答案

我也不得不四处寻找才能得到这个.这是我所做的

I too had to dig around to get this. Here is what I did

  1. 把它放在 spec_helper.rb 中:

  1. Put this in spec_helper.rb:

config.before :suite do
  PerfTools::CpuProfiler.start("/tmp/rspec_profile")
end

config.after :suite do
  PerfTools::CpuProfiler.stop
end

  • 运行你的 rspec

  • Run your rspec

    运行 pprof 获取您的号码

    Run pprof to get your numbers

    pprof.rb --text  /tmp/rspec_profile
    

  • 这篇关于如何使用 perftools 和 bundler 分析 RSpec?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆