mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-24 04:46:05 +08:00
[profiler] Make it a bit more readable.
This commit is contained in:
@@ -177,15 +177,19 @@ task :profile do
|
||||
unless template = ENV['template']
|
||||
App.fail "Specify the path to a template with the `template' environment variable. For a list of templates, use: $ xcrun instruments -s"
|
||||
end
|
||||
|
||||
sim_home = File.expand_path('~/Library/Application Support/iPhone Simulator')
|
||||
app_name = App.config.bundle_name + '.app'
|
||||
processes = `ps -x -o 'pid,command'`.split("\n")
|
||||
|
||||
if pid_line = processes.find { |line| line.include?(sim_home) && line.include?(app_name) }
|
||||
pid, path = pid_line.match(/^(\d+)\s(.+)$/)[1..2]
|
||||
App.info 'Profile', path
|
||||
doc_name = "Beers-#{File.basename(template, File.extname(template))}"
|
||||
doc_path = File.join(App.config.versionized_build_dir('iPhoneSimulator'), doc_name)
|
||||
|
||||
App.info 'Profile', path
|
||||
sh "xcrun instruments -p #{pid} -t '#{template}' -D '#{doc_path}'"
|
||||
|
||||
if pid_line = processes.find { |line| line.include?('Instruments.app') }
|
||||
pid = pid_line.match(/^(\d+)\s/)[1]
|
||||
open_files = `lsof -a -p #{pid} | grep '#{doc_path}'`
|
||||
|
||||
Reference in New Issue
Block a user