You can use Easy Profiler to measure application performance. With You.i Platform, there are two ways to connect to Easy Profiler: directly, using C++, or from the Dev Panel. Coding in C++ is the preferred mechanism for profiling, and is the only way to profile application start up.
To configure and use Easy Profiler through C++ code changes, do the following:
App.cpp
file located at App/src/App.cpp: #include <utility/YiEasyProfiler.h>
Add CYIEasyProfiler::StartListening(port_number);
to the App::UserInit()
function of the App.cpp
file as shown below:
bool App::UserInit()
{
CYIEasyProfiler::StartListening(port_number);
}
The default port_number
for every target platform is 40800, except for LG webOS, where the default is 9930.
App.cpp
.Launch the Easy Profiler GUI executable file located at youiengine/<versionInstalled>/tools/easy_profiler/<DevPlatform>/profiler_gui.
The following is a screenshot of the Easy Profiler GUI:
If your app is running on a different system from Easy Profiler, be sure to use the IP address of the target platform instead of localhost
.
port_number
mentioned in StartListening(port_number)
.Click the Capture icon in the GUI to capture the data.
You can also call CYIEasyProfiler::StartCapture
and CYIEasyProfiler::StopCapture
in your application to programmatically initiate and end a data capture for a particular event, such as screen transition or button click.
For more information, see StartCapture()
and StopCapture()
API documentation.
Once the data is captured, you can save it as a .prof
file.
You can also use CYIEasyProfiler::WriteToFile
with a writable path to save the data being captured using Easy Profiler.
When done performing the steps in Connect to Easy Profile and Capture Data via C++, implement the Systrace functionality to measure the performance for React Native. We use JavaScript’s begin and end events to measure the performance for React Native:
--dev
option, for example: youi-tv generate -p osx --dev
.index.youi.js
file.
For example: import { Systrace } from "react-native"
.Call Systrace.setEnabled(true)
in the code where you want to start measuring the performance in React Native.
For example:
import React, { Component } from 'react';
import { createStackNavigator } from 'react-navigation';
import { AppRegistry, NativeModules, Systrace } from 'react-native'; // import Systrace here.
Systrace.setEnabled(true); // Call setEnabled to turn on the profiling.
...
AppRegistry.registerComponent('YiReactApp', () => YiReactApp);
Once the above steps are done, you can see the JavaScript’s events alongside the C++ events in the MessageQueue
thread.
Systrace allows you to mark JavaScript (JS) events with a tag and an integer value Capture the non-Timed JS events in EasyProfiler by adding the following code to the app code in addition to the steps mentioned in Capture Data via React Native:
Systrace.counterEvent("event_label", 10);
For more information, see Systrace counterEvent documentation.
The following screen shot illustrates markers for the non-Timed JS events in the EasyProfiler GUI:
You can also capture events that take place during the app initialization using the YI_START_EASY_PROFILER_CAPTURE_AT_INIT
macro
You can add the macro at the start of any .cpp
file, outside of functions, such as App.cpp
For example:
#include <utility/YiEasyProfiler.h>
YI_START_EASY_PROFILER_CAPTURE_AT_INIT;
HelloWorldApp::HelloWorldApp()
: m_pSpinAnimation(nullptr)
{
}
You can use CYIEasyProfiler::StopCaptureAfterNextDraw
to trigger CYIEasyProfiler::StopCapture()
when the app draws the next frame, it is used in conjunction with YI_START_EASY_PROFILER_CAPTURE_AT_INIT
.
The combination of these lets you capture everything up until the first draw, which is the bulk of any app’s initialization time.
Don’t forget to add the following header file to the .cpp file when you use the YI_START_EASY_PROFILER_CAPTURE_AT_INIT
macro: #include <utility/YiEasyProfiler.h>
The Dev Panel has a set of useful widgets to help you troubleshoot and debug your application - including direct access to the Profiler, without needing to modify your application.
As with the C++ method of connecting your app to Easy Profiler, you can launch and connect to a Profiler Server, or you can write profile data to a file and open it with Easy Profiler.
You.i TV recommends you perform profiling with Release builds
To enable the Dev Panel for your Release build, add InitializeDevPanel();
to UserInit()
in App.cpp
Remember to remove this when you are done profiling!
You can capture a file with your profile data that you open with Easy Profiler Note on some target platforms (such as 10ft devices and iOS) it’s hard to download generated files Using the Profiler Server is the better choice for those platforms.
Remember the following points when you use Easy Profiler as performance tooling:
Release
configuration to get the correct data to measure performance of an app running on the target platform.Debug
configuration provides detailed information on function calls through the JavaScript bridge, such as function name and type, which could result in enormous amounts of data consuming a lot of memory on low-end devices, while data captured with the Release
configuration provides information on the function calls without divulging details about the name of the function or method being called.You.i TV does not recommend using Easy Profiler on simulators as it will result in unexpected behavior.
The following table provides information on the color legend used in the Easy Profiler data:
Color Name | Hexadecimal | Associated Events | Notes |
---|---|---|---|
Congo Brown | 5e3643 | Creating Component, Measuring Component, Dispatching View Manager Command, Updating Component, Managing Children, Setting Children | |
Porsche (a shade of Orange) | eea160 | Processing JS Task, Processing Queued JS Tasks | |
Goblin (a shade of green) | 397b44 | Destroying Registry, Destroying Subtree, Calculating and Applying Layout | |
Spicy Mix (a shade of maroon) | 7a444a | Initializing Bridge, Loading and Starting Bridge, Calling JS Function | |
Antique Brass (a shade of brown) | bf7958 | Loading Application Script, Invoking Callback, Calling JS Function, Setting Variable, Handling Memory Pressure | |
Mineral Green | 3c5956 | Calling Native Module | |
Sushi (a shade of green) | 71aa34 | Calling Method | |
Matrix (a shade of Red) | a05b53 | Expanding Argument | |
Conifer (a shade of green) | b6d53c | Provides extra information related to data, type, component name, file name, calling function name | Only available with the Debug configuration |