Profiling system activity with function instrumentation enabled

You can perform a kernel event trace while running applications with function instrumentation enabled. Combining application and system profiling lets you log the events generated by the instrumentation code to the kernel event trace log. These events provide function entrance and exit times and thread call stacks.

This workflow is handy when you suspect that other processes are impacting an application's performance at startup because the kernel event trace tells you how much memory and CPU is consumed by different target processes. It's also useful for examining the interaction between a short-running program and other processes. However, any tracing activity should be limited to a few seconds because longer traces produce too much data to be useful.

To profile functions, your source files must be compiled with -finstrument-functions and your binaries linked with -lprofilingS; for details, see Enabling function instrumentation.

Note: You can run an application with profiling instrumentation from the command line. However, using the IDE is more convenient because the Application Profiler automates the requesting of data from the instrumented binary and presents the results in a easy-to-read format.
To profile system activity while measuring function runtimes:
  1. In the launch bar, expand the Launch Configuration dropdown (which is in the middle) and select the project that you want to profile.
  2. In the Launch Target dropdown (on the right), select the target for running your application.
  3. In the Launch Mode dropdown (on the left), select Profile.
  4. Click the Edit button (Icon: Edit button) on the right of the Launch Configuration dropdown.
  5. In the configuration editor window, click the Profile tab on the right to access the Application Profiler controls.
  6. Ensure that Functions Instrumentation is selected under Profiling Method and System Wide is selected under Profiling Scope.
  7. Optional: You can customize how the profiling tool behaves through the Options and Control panels.
    For details about these fields, see the Application Profiler reference.
  8. Check the System Profiler box at the bottom of the Profile tab to enable kernel event tracing.
  9. Optional: You can customize how the kernel event trace is done in the UI fields shown for this tool.
    The Wait interval text field lets you set a delay, in milliseconds, for starting the trace after the application is launched. The Kernel Log configuration dropdown lets you select the log configuration for controlling the trace. Or, you can modify the selected configuration by clicking Edit.
  10. Click OK to save the configuration changes and close the window.
  11. In the launch bar, click the Profile button (Icon: Profile button).

The IDE switches to the QNX Analysis perspective. If necessary, the IDE first builds the profiling variant of the binary. Then, it uploads the binary and starts running it on the target. At this time, a new session is created and displayed in the Analysis Sessions view. As the application runs, profiling results are sent to the IDE, which stores them in the new session and presents them in the Execution Time view.

The kernel event trace also runs and when it finishes, the IDE prompts you to open the log (.kev) file. If you choose Yes, the IDE switches to the QNX System Profiler perspective and displays the trace results. The application being profiled continues to run (assuming it hasn't terminated on its own) and you can still switch back to the QNX Analysis perspective to examine the profiling results at any time. Note that with function instrumentation, deep and shallow times have distinct meanings.

When viewing the trace results, you can extract any profiling data captured during the trace period into a new Application Profiler session.

Note: You can concurrently profile as many applications as you like and multiple instances of the same application. The results for each execution run appear in their own Application Profiler session, independently of other sessions.