Install and configure rubyprof

This commit is contained in:
Daniel Schädler 2025-03-16 13:22:08 +01:00
parent 954b62e06e
commit 99b6500e5f
4 changed files with 19 additions and 0 deletions

View File

@ -47,6 +47,7 @@ group :test, optional: true do
gem 'faker'
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'ruby-prof'
end
group :development, optional: true do

View File

@ -267,6 +267,7 @@ GEM
rack (>= 1.1)
rubocop (>= 1.33.0, < 2.0)
rubocop-ast (>= 1.31.1, < 2.0)
ruby-prof (1.7.1)
ruby-progressbar (1.13.0)
shoulda-matchers (6.2.0)
activesupport (>= 5.2.0)
@ -334,6 +335,7 @@ DEPENDENCIES
rubocop
rubocop-performance
rubocop-rails
ruby-prof
shoulda-matchers
solargraph
spring

View File

@ -99,4 +99,7 @@ RSpec.configure do |config|
Kernel.srand config.seed
config.example_status_persistence_file_path = 'specs_with_runtime.txt'
# Run ruby-prof
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
end

13
spec/support/profile.rb Normal file
View File

@ -0,0 +1,13 @@
require 'ruby-prof'
RSpec.configure do |config|
config.around(:each) do |example|
profile = RubyProf::Profile.new
profile.start
example.run
result = profile.stop
printer = RubyProf::FlatPrinter.new(result)
printer.print(File.open("profile_#{example.full_description.parameterize}.txt", 'w+'))
end
end