1
mirror of https://github.com/rapid7/metasploit-framework synced 2024-07-18 18:31:41 +02:00

Profiling support for msfconsole boot

Set METASPLOIT_FRAMEWORK_PROFILE=true in the environment.  Run
`./msfconsole -q -x exit`.  A pdf will be saved to
tmp/profiles/msfconsole/YYYYMMDDHHMMSS.pdf with the call graph with
numbers being in 100 samples per second.  The pdf is automatically
opened with `open`.
This commit is contained in:
Luke Imhoff 2014-09-18 14:09:38 -05:00
parent b5c3c87790
commit 21b3d6bb4a
No known key found for this signature in database
GPG Key ID: 5B1FB01FB33356F8

View File

@ -11,6 +11,33 @@
require 'pathname'
if ENV['METASPLOIT_FRAMEWORK_PROFILE'] == 'true'
gem 'perftools.rb'
require 'perftools'
formatted_time = Time.now.strftime('%Y%m%d%H%M%S')
root = Pathname.new(__FILE__).parent
profile_pathname = root.join('tmp', 'profiles', 'msfconsole', formatted_time)
profile_pathname.parent.mkpath
PerfTools::CpuProfiler.start(profile_pathname.to_path)
at_exit {
PerfTools::CpuProfiler.stop
puts "Generating pdf"
pdf_pathname = "#{profile_pathname}.pdf"
if Bundler.clean_system("pprof.rb --pdf #{profile_pathname} > #{pdf_pathname}")
puts "PDF saved to #{pdf_pathname}"
system("open #{pdf_pathname}")
end
}
end
#
# Project
#