Android* Target Analysis from the Command Line
Use the
) and view the analysis result locally from the command line or GUI.
Intel® VTune™
to collect data on a remote Android application from the host system (remote usage mode) via command line interface ( Profiler
vtune
You may run the following analysis types on Android systems:
Configure and Run Performance Analysis on Android System
Remote data collection using the
command running on the host is very similar to the native collection on the target except that the
option is added to the command line.
vtune
Prerequisites:
Make sure to prepare a target Android* system and your application for analysis.
To run an analysis on an Android device:
- Launch your application on the target device.
- Find out<pid>or<name>of the application running on remote Android system. For example, you can use adb shell ps command for the purpose:adb shell ps ... root 2956 2 0 0 c1263c67 00000000 S kworker/u:3 u0_a34 8485 174 770232 54260 ffffffff 00000000 R com.intel.tbb.example.tachyon shell 8502 235 2148 1028 00000000 b76bcf46 R ps ...
- Optional: If you have several Android devices, you may set theANDROID_SERIALenvironment variable to specify the device you plan to use for analysis. For example:export ANDROID_SERIAL= emulator-5554orexport ANDROID_SERIAL=10.23.235.47:5555
- On the development host, runto collect data.vtuneBy default, theutility is located in the following directory:vtune
- On Windows*:<>\bin{32,64}
- On Linux*:<>/bin{32,64}
Use the following syntax to run an analysis:host>./-target-system=android:vtunedeviceName-<action> <analysis_type> [-duration <duration_value>][-r <result_path>] [-search-dir=<search_dir>] [-source-search-dir=<source_search_dir>] - <target_application>where:- is the name of your Android device, for example: Medfield2B3E703C . If you do not specify the name of the device, thedeviceNameVTuneuses the default device specified withProfileradb. You do not need to specify the device name if you set theANDROID_SERIALenvironment variable before the collection.
- is the action to perform the analysis (<action>collectorcollect-with)
- <is a predefined analysis type, such asanalysis_type>hotspots,uarch-exploration, and so on
- <is the duration in secondsduration_value>
- <is a PATH/name of the directory where a result is storedresult_path>
- <is a path to search for binary files used by your Android applicationsearch_dir>
- <is a path to search for source files used by your Android applicationsource_search_dir>
- <is an application to analyze. The command option depends on analysis target type:target_application>
- To specify an application (a native Linux* application running on Android) or a script to analyze, enter the path to the application or the script on your host system.This target type is not supported for the Hotspots analysis of Android applications.
- To specify an Android application package to analyze, enter the name of the Android package installed on a remote device.
- To specify a particular process to attach to and analyze, use the-target-processcommand to specify application by process name or the-target-pidcommand to specify the application by process PID.
- To profile your Android system, do not specify target application.System-wide analysis is possible on rooted devices only.
- Optional: You can sendpauseandresumecommands during collection from another console window, for example:host>./vtune -C pause -r tachyon_r001host>./vtune -C resume -r tachyon_r001
- If you do not specify analysis duration, you can stop analysis by pressingCtrl-Cor sending thestopcommand from another console on the host development system:vtune -r tachyon_r001 -C stop
You may use the
Command Line...
option in the
VTune
graphical interface to automatically
generate a command line for an analysis configuration selected in the GUI.
Profiler
Hotspots Analysis (User-Mode Sampling)
In this mode, you can:
- Run analysiswithoutroot access (although, root access is required for Java* analysis)
- Run the Hotspots analysis (if a target process or PID is specified) to identify functions that take the most time to execute (hotspots)
- Explore call stacks
- View C/C++ generated functions/source
- (If installed) Automatically obtain Java function names for functions that have been JITed and drill down to either JIT assembly or Java source or DEX Byte CodeJava analysis is not supported for the 4th Generation Intel® Core™ processors (based on Intel microarchitecture code name Haswell).
Example
This example runs Hotspots analysis on target Android system.
host>./vtune -collect hotspots -target-system=android -r tachyon_r@@@ -- com.intel.tbb.example.tachyon
Event-Based Sampling Analysis
In this mode, you can:
- Use hardware event-based sampling analysis types with event groups predefined by Intel architects
- View C/C++ generated functions/source
- Explore call stacks (if a target process or PID is specified)
- Analyze performance system wide (if call stack analysis is disabled)
- (If installed) Automatically obtain Java function names for functions that have been JITed and drill down to either JIT assembly or Java source or DEX Byte CodeJava analysis is not supported for the 4th Generation Intel® Core™ processors (based on Intel microarchitecture code name Haswell) or systems using ART.
The following event-based sampling analysis types are supported by the
VTune
on Android systems:
Profiler
To associate JITed Java functions to samples in the system-wide event-based sampling, you have the following two options:
- Specify-target-processfor the process you are interested in similar to how you do this for the event-based call stack collection.Proccess.Name
- For any process you are interested in, copy the JIT files for the PID of that process into thedata.0directory, and re-resolve the results in theVTuneGUI:Profiler
- Collect results:host>./vtune -collect <analysis_type> -duration=60 -target-system=android -r system_wide_r@@@
- Find PID of interesting processes:adb shell ps | [grep MyApp] u0_a79 1762 141 575912 75468 ffffffff 4006f2ef Scom.android.MyApp
- Copy alljitfiles for processes you are interested in to thedata.0directory:adb pull /data/vtune/results/localhost.1762*.jit system_wide_r000/data.0
Examples
Example 1: Microarchitecture Exploration Analysis
This example launches specified Android package and collects a complete list of events required to analyze typical client applications running on the 4th Generation Intel Core processor.
host>./vtune -collect uarch-exploration -target-system=android -r tachyon_r@@@ -target-process com.intel.tbb.example.tachyon
Example 2: Call Stack Analysis
By default, the
VTune
does not collect stack data during hardware event-based sampling. To enable call stack analysis, use the
Profiler
enable-stack-collection=true
knob. For example:
host>./vtune -collect hotspots -knob sampling-mode=hw -knob enable-stack-collection=true -target-system=android -r tachyon_r@@@ -target-process com.intel.tbb.example.tachyon
Example 3: System-wide Data Collection
To analyze performance of your target application and all other processes running on the Android system, use the
--duration
option and do not specify an analysis target.
host>./vtune -collect hotspots -knob sampling-mode=hw -target-system=android -duration=60 -r system_wide_r@@@
Example 4: Unplugged Mode Collection
This example configures the Hotspots analysis for the application on an Android system that will be launched after disconnecting the device from the USB cable or a network:
host>./vtune --collect hotspots --target-system=android -unplugged-mode -r quadrant_r@@@ --target-process com.intel.fluid
Custom Analysis
Use the
-collect-with
option to configure
VTune
to run a custom user-mode sampling and tracing ( Profiler
runss
) or event-based sampling (runsa
) analysis and take other than default configuration options. For example, to run a custom event-based sampling analysis, use the
-collect-with
option and specify required event counters with the
-knob event-config
option as follows:
host>./vtune -collect-with runsa -target-process com.intel.tbb.example.tachyon -r system_wide_r001 -knob collection-detail=stack-sampling [-event-mux] -knob event-config=CPU_CLK_UNHALTED.REF_TSC:sa=1800000,CPU_CLK_UNHALTED
To display a list of events available on the target PMU, enter:
vtune
collector
> -target-system=android:deviceName
-knob event-config=? <target_application
> You can take any counter that the Performance Monitoring Unit (PMU) of that processor supports. Additionally, you can enable multiple counters at a time. Each processor supports only a specific number of counters that can be taken at a time. You can take more events than the processor supports by using the
-event-mux
option, which will round robin the events you specified on the available counters in that processor.
Typically, you are recommended to use analysis types with the predefined sets of counters. Use of specific counters is targeted for advanced users. Please note that names of some counters may not exactly correspond to the analysis scope provided with these counters.
After collecting these counters,
import the result to the
VTune
GUI and explore the
Microarchitecture Explorationdata.
Profiler