The Intel® XDK includes a profiler to analyze the performance of the JavaScript* code in your Android* app. The profiling tool identifies functions that take the most time to execute (hotspots). You identify hotspots in your code based on the profiler's analysis of your application's call flow and the execution time spent in each JavaScript function.
NOTE: This tab functions only after you connect an Android 4.x mobile device to your development system with a USB cable. That device must be configured for Developer mode and USB debugging. You do not have to "root" your device to use this feature.
With this feature, currently included as a developer preview, you can develop HTML5 code in the Intel XDK and immediately profile your application directly from within the Intel XDK while it runs on a USB-connected Android device. The profiler collects statistics on which portions of your code are using the most CPU cycles and enables you to view those statistics so you can see exactly where in your source code your app is spending the most time.
An Intel XDK component called App Preview Crosswalk* (formerly App Analyzer) is automatically downloaded and installed over the USB connection onto your Android device the first time you use this feature. App Preview Crosswalk facilitates profiling your JavaScript code by remotely collecting execution time data from your app without creating and installing an executable image (an APK).
Remote Profiling using App Preview Crosswalk uses the Crosswalk* portable application runtime. App Preview Crosswalk is an Apache Cordova* application based on the Crosswalk Project.
Profile Tab Requirements
When you profile your application with this feature, the Intel XDK pushes your application to a Crosswalk portable runtime (aka WebView or container – App Preview Crosswalk) on your Android device. The Crosswalk portable runtime is built on top of the Chromium* content module and Blink* rendering and layout engine. This means that it shares many of the features found in the Google Chrome* browser on your desktop. In addition to the standard Crosswalk APIs the runtime also includes an implementation of the Apache Cordova* device API.
Your development environment and project must meet the following requirements to use this profiling feature:
Your project source code to be profiled should be neither obfuscated nor minified.
Applications to be profiled are limited to using standard HTML5 APIs and Cordova device APIs. We currently support the Cordova 3.X APIs.
There is no support for the
intel.xdk.*
orappmobi.*
device APIs; the only exceptions being theintel.xdk.device.ready()
andintel.xdk.device.hideSplashScreen()
functions.Your Android device must be running version 4.0 or higher of the Android OS and USB debugging must be enabled (described on the Debug tab page, see note below).
Profiling from a Microsoft Windows* development system requires that you obtain and install the OEM USB driver specific to your Android device onto your Windows development system.
You do not need to install the Android SDK; all components needed to communicate with your Android device (other than the necessary USB drivers mentioned above) are provided automatically by the Intel XDK.
It is not necessary to "root" your device in order to use this feature.
NOTE: For details regarding how to enable your Android device for connection and profiling over a USB cable, please see the "Instructions to Setup a Debug Session" on the Debug tab help page. The same mechanism that enables remote debugging with Chrome* Developer Tools (CDT) is also used to facilitate profiling.
Profiling Your Application
A typical profiling session includes the following actions:
Select the debug device from the drop-down device list (left edge of the Profile toolbar).
Make sure the selected Android device is on, not in sleep mode and unlocked (your device's home screen is visible).
Load and start your application with the
Launch button.
Setup your application on the device so it is ready to profile the activities of interest.
Click the
Profile button to begin code execution data collection by the profiler.
Interact with your application on the device in a manner that will execute the code you wish to profile.
After all activities to be profiled have been completed, click the
Profile button a second time to stop data collection.
Review code execution data using the Profile tab's analysis display.
Alternatively, you may load and start profiling your application in one step by starting the Profile button. It will automatically load and begin profiling your application from initial execution. Profiling will end when you push the
Profile button a second time.
Clicking the Close button will close your app and discard any profile data that has been collected during that session.
You may record as many profiling sessions as you want by repeating the steps above. While the Intel XDK is open it retains the results of all profiling sessions. All profile session results are deleted when you close the Intel XDK.
Analyzing Profiling Data
When you end a profiling session the results of your session are displayed in the Profile tab, for example:
The Function column displays a list of JavaScript functions used in your app during the profiling session. Click the column header to sort the functions in alphabetical order. Clicking the small triangle icon in front of a function name reveals any child functions called by the selected function and allows you to explore how much time it took to execute each function within the call path.
The Self Time column displays the amount of time (in seconds) spent on function execution in a particular call tree. By default, the data view in the Profile tab is sorted in descending order. The most time-consuming functions are listed first. Click the column header to reverse the sorting order.
The Usage column shows the percentage of Self Time spent on a function execution, relative to the entire application execution time. For better visibility, the Usage metric is also represented with colored bars where high Usage values correspond to longer bars, colored according to the range of Self Time values: green (lowest) < yellow < orange < red (highest). Click the column header to reverse the sorting order.
Source view is available when you double-click a function in the data view. By default, the source file opens on the code line introducing the selected function. The Self Time column in the Source view shows the amount of time (in seconds) spent executing a particular code line.
The Heat map indicators show the location of code lines with Self Time values. Indicators in darker colors point to code lines with higher Self Time values. Move the scroll bar to navigate between heat map indicators and quickly identify the most time-critical code lines.
The Result drop-down menu lists all the profiling results collected for the selected project during this session.