Skip to content

Commit

Permalink
Merge pull request #11695 from fatkodima/print-profile-locations
Browse files Browse the repository at this point in the history
Print locations of generated profile files when profiling rubocop
  • Loading branch information
koic authored Mar 15, 2023
2 parents 3ecd550 + 2a91feb commit 2033fa5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/rubocop/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -87,20 +87,20 @@ def profile_if_needed

tmp_dir = File.join(ConfigFinder.project_root, 'tmp')
FileUtils.mkdir_p(tmp_dir)
cpu_profile_file = File.join(tmp_dir, 'rubocop-stackprof.dump')
status = nil

StackProf.run(out: File.join(tmp_dir, 'rubocop-stackprof.dump')) do
StackProf.run(out: cpu_profile_file) do
status = yield
end
puts 'Profile report generated'
puts "Profile report generated at #{cpu_profile_file}"

if with_memory
puts 'Building memory report...'
report = MemoryProfiler.stop
report.pretty_print(
to_file: File.join(tmp_dir, 'rubocop-memory_profiler.txt'),
scale_bytes: true
)
memory_profile_file = File.join(tmp_dir, 'rubocop-memory_profiler.txt')
report.pretty_print(to_file: memory_profile_file, scale_bytes: true)
puts "Memory report generated at #{memory_profile_file}"
end
status
end
Expand Down

0 comments on commit 2033fa5

Please sign in to comment.