Class: Instrumentality::Benchmark

Inherits:
Command
  • Object
show all
Defined in:
lib/instrumentality/command/benchmark.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Benchmark

Returns a new instance of Benchmark.



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/instrumentality/command/benchmark.rb', line 28

def initialize(argv)
  @process = argv.shift_argument
  @workspace = argv.option('workspace') || Finder.find_workspace
  @project = argv.option('project')
  @project ||= Finder.find_project if @workspace.nil?
  @scheme = argv.option('scheme') || @process
  @server_port = argv.option('server-port') || Constants::DEFAULT_SERVER_PORT
  @interactive = argv.flag?('interactive', false)
  @experimental = argv.flag?('experimental', false)
  super
end

Class Method Details

.optionsObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/instrumentality/command/benchmark.rb', line 9

def self.options
  [
    ['--workspace=path/to/name.xcworkspace', 'If not set, Instr will try to find one'],
    ['--project=path/to/name.xcodeproj', 'If not set and workspace search failed, Instr will try to find one'],
    ['--scheme=name', 'If not set, Instr will use the process name'],
    ['--server-port=port_number', 'If not set, Instr will use 8080'],
    ['--interactive', 'If set, Instr will not attempt to run an Xcode scheme, but instead attach DTrace directly'],
    ['--experimental', "Don't use it if you don't know what it does"],
  ].concat(super)
end

Instance Method Details

#runObject



48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/instrumentality/command/benchmark.rb', line 48

def run
  config = OpenStruct.new({'script' => Constants::BENCHMARK_SCRIPT,
                           'process' => @process,
                           'workspace' => @workspace,
                           'project' => @project,
                           'scheme' => @scheme,
                           'server_port' => @server_port,
                           'interactive' => @interactive,
                           'experimental' => @experimental})
  profiler = Profiler.new(config, @verbose)
  profiler.profile
end

#validate!Object



40
41
42
43
44
45
46
# File 'lib/instrumentality/command/benchmark.rb', line 40

def validate!
  super

  help! 'A process name is required' unless @process
  return if @interactive
  help! 'Xcode workspace or project files not found' if @workspace.nil? && @project.nil?
end