lunedì 13 ottobre 2014

Collect iphone/ipad metrics (cpu, memory, network, disk, etc) with instruments command


Do you want to check what is the cpu used, the memory consumed, the network traffic, the disk usage etc? 
Do you need to improve performances of your app on the iOS device? Here you can see how to check metrics. 

Connect your iOS device with USB to a Mac, grant access, then follow these steps:

1) Open XCode --> open Developer Tool --> Instruments

2) Create a new Activity Monitor template, select all statistics you need with the configure panel:


 
and associate the template to the iOS device:


3) Save as template (i.e ActivityMonitor.tracetemplate )

4) On the device starts collecting metrics running this command from a shell on the Mac:

instruments -t ActivityMonitor.tracetemplate -w 0345678ab0b6fg8b4c3a2aaa5b9876bc22ab4567b

(note: the id of the device is printed out with this command: idevice_id -l)

5) Perform the scenario on the device where you want to check performance
 

6) When the scenario is completed close instruments command (CTRL+C) --> it display out the name of the folder where results are collected.

7) Open Instruments UI program and open the output folder name of step above. You can display all samples with related metric value.

8) To export data collect as CSV, select Sample like in this screenshot:


9) Select menu Instrument--> Export Track for 'Activity Monitor', this export as CSV the data. In this way you export for each process the average statistics of all samples for each metric specified on the template.

With this interesting and useful parser program (AMParser found in GitHub) you can parse the output of the instruments (step 6) and display by command line the metrics collected.

Nessun commento:

Posta un commento