Class: Homebrew::DevCmd::Prof Private

Inherits:
AbstractCommand show all
Defined in:
sorbet/rbi/dsl/homebrew/dev_cmd/prof.rbi,
dev-cmd/prof.rb

Overview

This class is part of a private API. This class may only be used in the Homebrew/brew repository. Third parties should avoid using this class if possible, as it may be removed or changed without warning.

DO NOT EDIT MANUALLY This is an autogenerated file for dynamic methods in Homebrew::DevCmd::Prof. Please instead update this file by running bin/tapioca dsl Homebrew::DevCmd::Prof.

Defined Under Namespace

Classes: Args

Instance Method Summary collapse

Methods inherited from AbstractCommand

command, command_name, dev_cmd?, #initialize, parser

Constructor Details

This class inherits a constructor from Homebrew::AbstractCommand

Instance Method Details

#argsHomebrew::DevCmd::Prof::Args

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.



9
# File 'sorbet/rbi/dsl/homebrew/dev_cmd/prof.rbi', line 9

def args; end

#runvoid

This method is part of a private API. This method may only be used in the Homebrew/brew repository. Third parties should avoid using this method if possible, as it may be removed or changed without warning.

This method returns an undefined value.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'dev-cmd/prof.rb', line 20

def run
  Homebrew.install_bundler_gems!(groups: ["prof"], setup_path: false)

  brew_rb = (HOMEBREW_LIBRARY_PATH/"brew.rb").resolved_path
  FileUtils.mkdir_p "prof"
  cmd = args.named.first

  case Commands.path(cmd)&.extname
  when ".rb"
    # expected file extension so we do nothing
  when ".sh"
    raise UsageError, <<~EOS
      `#{cmd}` is a Bash command!
      Try `hyperfine` for benchmarking instead.
    EOS
  else
    raise UsageError, "`#{cmd}` is an unknown command!"
  end

  Homebrew.setup_gem_environment!

  if args.stackprof?
    with_env HOMEBREW_STACKPROF: "1" do
      system(*HOMEBREW_RUBY_EXEC_ARGS, brew_rb, *args.named)
    end
    output_filename = "prof/d3-flamegraph.html"
    safe_system "stackprof --d3-flamegraph prof/stackprof.dump > #{output_filename}"
  else
    output_filename = "prof/call_stack.html"
    safe_system "ruby-prof", "--printer=call_stack", "--file=#{output_filename}", brew_rb, "--", *args.named
  end

  exec_browser output_filename
rescue OptionParser::InvalidOption => e
  ofail e

  # The invalid option could have been meant for the subcommand.
  # Suggest `brew prof list -r` -> `brew prof -- list -r`
  args = ARGV - ["--"]
  puts "Try `brew prof -- #{args.join(" ")}` instead."
end