主要内容

Profiling Real-Time Applications

Profiling measures the execution time and resource usage of tasks, functions, or threads running on a target computer. Use profiling metrics to identify performance bottlenecks, verify timing constraints for real-time applications, and optimize CPU utilization. Profiling is essential for optimizing CPU usage and tuning models for multicore execution.

Simulink® Real-Time™ enables you to generate profiling data for an application running on the target computer and download the data to the host computer as a PERF file. This file contains detailed profiling information, including event samples, symbolized function names, and metadata about the system and workload.

Generate Profiler Data

Follow these steps to generate and download profiler data for a real-time application:

  1. Create and deploy a real-time application on the target computer.

  2. Start the profiler. You must start the profiler before you start the application.

    startProfiler(tg);

  3. Start the application and tune the parameters as needed.

    startApplication(tg);

  4. Stop the application.

    stop(tg);
    When you stop the application, the profiler stops. To continue running the application and stop only the profiler, use stopProfiler(tg) instead.

  5. Download the profiler data.

    getProfilerData(tg);

Simulink Real-Time downloads the profiler data for the application and saves it as profilingData_app_name.perf in the current MATLAB path, where app_name is the name of the real-time application.

Applications of Profiler Data

Profiler data contains performance event samples and metadata from a profiling session for an application running on the target computer.

Key applications include:

  • Identifying CPU hotspots in applications

  • Determining which functions or code paths consume the most CPU cycles

  • Detecting lock contention, I/O stalls, and thread scheduling delays

  • Investigating cache misses, branch mispredictions, and other hardware-level inefficiencies

  • Understanding calling contexts of expensive functions using recorded call stacks

  • Verifying timing constraints and ensure tasks meet deadlines

  • Optimizing CPU utilization and tune models for multicore execution

See Also

| | |

Topics