Using prebuilt binaries¶
The Profiling Helper Tool plugin package contains prebuilt Win64 and Android framework binaries that you can use to integrate the plugin with your application without compiling Profiling Helper Tool source code.
When using prebuilt binaries, Profiling Helper Tool does not extract startup profiling data. See Startup profiling.
Using prebuilt binaries with an existing application executable on Windows¶
You can integrate Profiling Helper Tool binaries to an existing application executable. When doing this, you do not need to recompile the application.
To use prebuilt Profiling Helper Tool binaries with an existing application executable:
Copy the
ProfilingHelper.dllbinary that matches the build tool version and configuration used to compile your application to the<ProjectFolder>/Application/bindirectory.For example, if the application is built using the Visual Studio 2019 compiler and
Profilingconfiguration, useProfilingHelper.dllfrom theprofilinghelper/lib/GL_vs2019_Profiling_DLLdirectory.In
<ProjectFolder>/Application/bin/application.cfg, addProfilingHelperto theModuleNamesconfiguration option. See ModuleNames application configuration option.ModuleNames = "ProfilingHelper"
When you launch the application, profiling results are stored in
<ProjectFolder>/Application/bin/tracing_output.json. To configure Profiling Helper Tool, see Configuring Profiling Helper Tool.
Using prebuilt binaries with an existing Visual Studio solution¶
To use prebuilt Profiling Helper Tool binaries with an existing Visual Studio solution:
Open the
CMakeLists.txtfile of your application and add prebuilt binaries to the Visual Studio working environment:set(BUILD_OUTPUT_FOLDER_NAME "GL_${MSVC_VERSION_TAG}_$<CONFIG>_DLL") set_target_properties(ApplicationTest PROPERTIES VS_DEBUGGER_ENVIRONMENT "${KANZI_VS_DEBUGGER_ENVIRONMENT};$ENV{KANZI_HOME}/Engine/plugins/profilinghelper/lib/Win64/${BUILD_OUTPUT_FOLDER_NAME}")
In
<ProjectFolder>/Application/bin/application.cfg, enable all profilers and addProfilingHelperto theModuleNamesconfiguration option. See ModuleNames application configuration option.# Enables all performance profiling categories. ProfilingCategoryFilter="*=on" ModuleNames = "ProfilingHelper"
When you launch the application, profiling results are stored in
<ProjectFolder>/Application/bin/tracing_output.json. To configure Profiling Helper Tool, see Configuring Profiling Helper Tool.
Using prebuilt binaries with an existing Android application¶
You can use the prebuild Android binaries of Profiling Helper Tool with Android applications based on Android framework or Android with the Kanzi application framework.
In the
application.cfgfile of your application, enable all profilers and add theProfilingHelperto the list of modules.Enabling the profilers does not affect application performance of the Debug or Release builds, because profiling measurements are performed only in the Profiling build.
# Enables all performance profiling categories. ProfilingCategoryFilter="*=on" ModuleNames = "ProfilingHelper"
To save the profiling data to the filesystem, in the
Application/configs/platforms/android_gradle/app/src/main/AndroidManifest.xml, enable the read and write permission.For Android SDK version 30 and newer:
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
For Android SDK version older than 30:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
Create a pop-up when the application starts where you ask for file system access permission. Android requires users to confirm permission requests. This approach makes it easier to enable permissions than it is to do so manually in the application settings.
In the Java file that contains the main activity of your application, add the
requestReadWritePermissionsfunction.For Android SDK version 30 and newer:
void requestReadWritePermissions() { // Check and request permission to read and write to external storage. // Android SDK 30 and above requires MANAGE_EXTERNAL_STORAGE. if(SDK_INT >= Build.VERSION_CODES.R) { if (!Environment.isExternalStorageManager()) { Uri uri = Uri.parse("package:" + BuildConfig.APPLICATION_ID); Intent intent = new Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION, uri); startActivity(intent); } } }
For Android SDK version older than 30:
void requestReadWritePermissions() { // Check and request permission to read and write to external storage. // Android SDK 30 and above requires WRITE_EXTERNAL_STORAGE. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED ||checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 0); } } }
Call the
requestReadWritePermissionsfunction in theonCreatefunction of your activity.@Override protected void onCreate(Bundle icicle) { // Request the permissions. requestReadWritePermissions();
In Android Studio, set the build configuration to Profiling.
This way you enable Kanzi Engine to collect profiling data at runtime.
On Kanzi Android framework, Profiling Helper Tool by default outputs profiling results to the
sdcarddirectory.
In Android Studio, add Profiling Helper Tool binaries to dependencies section in the
build.gradlefile of the application.dependencies { debugImplementation files(getKanzi().toString() + '/Engine/plugins/profilinghelper/lib/android/profilinghelperplugin-debug.aar') profilingImplementation files(getKanzi().toString() + '/Engine/plugins/profilinghelper/lib/android/profilinghelperplugin-profiling.aar') releaseImplementation files(getKanzi().toString() + '/Engine/plugins/profilinghelper/lib/android/profilinghelperplugin-release.aar')