Main Content

View Execution Times

When you run a SIL or PIL execution with execution time profiling enabled, the software generates a message in the Test Output tab. For example:

Current plot held
### Starting SIL execution for 'kalman01'
    To terminate execution: clear kalman01_sil
    Execution profiling data is available for viewing. Open Simulation Data Inspector.
    Execution profiling report available after termination.
Current plot released

To observe streamed execution times while the execution runs, click the Simulation Data Inspector link.

To open the code execution profiling report:

  1. Click the Stop SIL Verification link.

    The software terminates the execution process and displays a new link.

    ### Stopping SIL execution for 'kalman01'
        Execution profiling report: report(getCoderExecutionProfile('kalman01'))

  2. Click the new link.

The report provides:

  • A summary.

  • Information about profiled code sections, which includes time measurements for:

    • The entry_point_fn_initialize function, for example, kalman01_initialize.

    • The entry-point function, for example, kalman01.

    • The entry_point_fn_terminate function, for example, kalman01_terminate.

  • Definitions for metrics.

By default, the report displays time in nanoseconds (10-9 seconds). You can specify the time unit and numeric display format. For example, to display time in microseconds (10-6 seconds), use the report command:

% Create workspace variable

report(executionProfile, ...
       'Units', 'Seconds', ...
       'ScaleFactor', '1e-06', ...
       'NumericFormat', '%0.3f')

The report displays time in seconds only if the timer is calibrated, that is, the number of timer ticks per second is established. On a Windows® machine, the software determines this value for a SIL simulation. On a Linux® machine, you must manually calibrate the timer. For example, if your processor speed is 1 GHz, specify the number of timer ticks per second:

executionProfile.TimerTicksPerSecond = 1e9;

To view execution-time metrics for a code section in the Command Window, on the corresponding row, click the icon .

To display measured execution times, click the Simulation Data Inspector icon . You can use the Simulation Data Inspector to manage and compare plots from various executions.

To display the execution-time distribution, click the icon .

In this example, to create the histogram, the software uses these commands:

histogram(data, 30,'Normalization','probability');
The software creates the histogram only if the number of calls to the function is greater than one.

The following table lists the information provided in the code section profiles.

SectionName of function from which code is generated.
Maximum Execution TimeLongest time between start and end of code section.
Average Execution TimeAverage time between start and end of code section.
Maximum Self TimeMaximum execution time, excluding time in child sections.
Average Self TimeAverage execution time, excluding time in child sections.
CallsNumber of calls to the code section.
Icon that you click to display the profiled code section.
Icon that you click to display measured execution times with Simulation Data Inspector.
Icon that you click to display the execution-time distribution for the profiled code section.

Related Topics