Skip to content

Instantly share code, notes, and snippets.

@ndemianc
Created June 29, 2018 21:41
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ndemianc/b963f4a095f4bf2aea27eed56cf45842 to your computer and use it in GitHub Desktop.
How to use Ruby Prof to profile Sidekiq Worker
# How to use Ruby Prof to profile Sidekiq Worker
require 'ruby-prof'
result = RubyProf.profile do
#Code to analyse in a method
EsIndexWorker.new.perform
end
# Print a graph profile to text
printer = RubyProf::GraphHtmlPrinter.new(result)
File.open(File.join(Rails.root || __dir__, 'profile_output.html'), 'w') do |file|
printer.print(file, {:min_percent => 10, :print_file => true})
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment