ruby-on-rails - 如何使用 perftools 和 bundler 分析 RSpec?

标签 ruby-on-rails ruby rspec profiling google-perftools

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

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

最佳答案

我也不得不四处挖掘才能得到这个。这是我做的

  1. 将其放入 spec_helper.rb:

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

  3. 运行 pprof 获取你的数字

    pprof.rb --text  /tmp/rspec_profile
    

关于ruby-on-rails - 如何使用 perftools 和 bundler 分析 RSpec?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9680481/

相关文章:

ruby-on-rails - Rails RSpec 测试简单链接redirect_to 路径

ruby-on-rails - 使用 rspec 测试该方法在另一个方法中被调用

ruby-on-rails - 在 Ruby 数据库中存储使用自定义类的哈希值

ruby-on-rails - Rails 应用程序中对/etc/localtime 的过多 stat 调用

ruby-on-rails - rails : Is there a built translation for "ago"?

ruby - Dockerfile:尝试安装 ruby​​-build 时权限被拒绝

ruby-on-rails - CommentsController :Class in my destroy comment method 的未定义局部变量或方法 `destroy'

ruby - 如何在 WebSocket 聊天应用程序中跟踪用户(连接)

ruby - "wrong number of arguments"使用圆形时出现 ArgumentError

ruby - capybara select2 助手