2019-04-17 18:25:08 +09:00
|
|
|
require "cli/parser"
|
2019-03-09 13:00:15 -05:00
|
|
|
|
2018-02-27 12:07:30 +00:00
|
|
|
module Homebrew
|
|
|
|
module_function
|
|
|
|
|
2018-10-08 22:48:52 -04:00
|
|
|
def prof_args
|
|
|
|
Homebrew::CLI::Parser.new do
|
|
|
|
usage_banner <<~EOS
|
2019-01-30 21:33:03 +00:00
|
|
|
`prof` <command>
|
2018-10-08 22:48:52 -04:00
|
|
|
|
2019-01-30 21:33:03 +00:00
|
|
|
Run Homebrew with the Ruby profiler e.g. `brew prof readall`.
|
2018-10-08 22:48:52 -04:00
|
|
|
EOS
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-02-27 12:07:30 +00:00
|
|
|
def prof
|
2019-03-27 11:49:56 +00:00
|
|
|
prof_args.parse
|
|
|
|
|
2018-02-27 12:07:30 +00:00
|
|
|
Homebrew.install_gem_setup_path! "ruby-prof"
|
|
|
|
FileUtils.mkdir_p "prof"
|
|
|
|
brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
|
2019-03-27 21:15:20 +00:00
|
|
|
safe_system "ruby-prof", "--printer=multi", "--file=prof", brew_rb, "--", *ARGV
|
2018-02-27 12:07:30 +00:00
|
|
|
end
|
|
|
|
end
|