Skip to content

Instantly share code, notes, and snippets.

@cprice404
Created May 17, 2012 21:26
Show Gist options
  • Save cprice404/2721671 to your computer and use it in GitHub Desktop.
Save cprice404/2721671 to your computer and use it in GitHub Desktop.
Callgrind profile data for a puppet client run
#!/usr/bin/env ruby
require 'ruby-prof'
RubyProf.measure_mode = RubyProf::PROCESS_TIME
#RubyProf.measure_mode = RubyProf::ALLOCATIONS
#RubyProf.measure_mode = RubyProf::MEMORY
RubyProf.start
begin
require 'puppet/util/command_line'
Puppet::Util::CommandLine.new.execute
rescue SystemExit
# Grrrrrr.... It makes me sad that I have to do this
end
result = RubyProf.stop
printer = RubyProf::CallTreePrinter.new(result)
report_file = File.open("./profile.callgrind", "w")
printer.print(report_file)
report_file.close
~
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment