Last active
August 29, 2015 14:20
-
-
Save denyago/5df0c60e2e0d397c086a to your computer and use it in GitHub Desktop.
Ruby profiling
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# gem 'ruby-prof' | |
module WithProfiling | |
def self.run | |
RubyProf.start | |
puts 'Start' | |
result = yield | |
puts 'End' | |
result = RubyProf.stop | |
file_path = "/tmp/callgrind.#{Time.now.strftime('%Y-%m-%d_%H-%M-%S')}" | |
io = IO.new(IO.sysopen(file_path, 'w'), 'w') | |
printer = RubyProf::CallTreePrinter.new(result) | |
printer.print(io) | |
io.close | |
puts "qcachegrind #{file_path}" | |
result | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment