Class: Instrumentality::Profiler

Inherits:
Object
  • Object
show all
Defined in:
lib/instrumentality/profiler.rb

Defined Under Namespace

Classes: ProfilerError, ProfilerInterruptError

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config, verbose = false) ⇒ Profiler

Returns a new instance of Profiler.

Raises:



16
17
18
19
20
21
22
23
# File 'lib/instrumentality/profiler.rb', line 16

def initialize(config, verbose = false)
  @config = config
  @verbose = verbose
  script = config.script.dup
  script.prepend(Constants::EXPERIMENTAL) if @config.experimental
  @script_path = Finder.path_for_script(script)
  raise ProfilerError, "This intrument doesn't support --experimental flag".red unless File.exist?(script_path)
end

Instance Attribute Details

#app_pidObject (readonly)

Returns the value of attribute app_pid.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def app_pid
  @app_pid
end

#configObject (readonly)

Returns the value of attribute config.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def config
  @config
end

#dtrace_pidObject (readonly)

Returns the value of attribute dtrace_pid.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def dtrace_pid
  @dtrace_pid
end

#script_pathObject (readonly)

Returns the value of attribute script_path.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def script_path
  @script_path
end

#verboseObject (readonly)

Returns the value of attribute verbose.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def verbose
  @verbose
end

#xcodebuild_pidObject (readonly)

Returns the value of attribute xcodebuild_pid.



14
15
16
# File 'lib/instrumentality/profiler.rb', line 14

def xcodebuild_pid
  @xcodebuild_pid
end

Instance Method Details

#profileObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/instrumentality/profiler.rb', line 25

def profile
  return interactive if @config.interactive
  current_directory = Dir.pwd
  Dir.mktmpdir do |tmpdir|
    compile(current_directory, tmpdir)
    Simctl.execute_with_simulator_ready(Constants::DEFAULT_RUNTIME, Constants::DEFAULT_DEVICE) do |device_udid|
      run_tests(tmpdir, device_udid)
      find_app_pid
      notify_server
      attach_dtrace(tmpdir)
      wait
    end
    process_dtrace_output(current_directory, tmpdir)
  end
end