View Execution Times
You can run a software-in-the-loop (SIL) or processor-in-the-loop (PIL) execution that produces execution-time metrics for tasks and functions in your generated code. During execution, you can use the Simulation Data Inspector to observe streamed execution times. When execution is complete, you can:
View execution-time metrics for a profiled entry-point function.
Open a report of execution-time metrics for all profiled functions. Through report icons, you can view, for example, the profiled code section and the execution-time distribution for each profiled function.
Use the Simulation Data Inspector to plot and compare execution times from various execution runs.
Code Execution Profiling Report
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. Go to 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:
Stop SIL Verificationlink.
The software terminates the execution process and displays a new link.
### Stopping SIL execution for 'kalman01' Execution profiling report: report(getCoderExecutionProfile('kalman01'))
Click the new link.
The report provides:
Information about profiled code sections, which includes time measurements for:
_initializefunction, for example,
The entry-point function, for example,
_terminatefunction, for example,
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
% Create workspace variable executionProfile=getCoderExecutionProfile('kalman01'); 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:
executionProfile=getCoderExecutionProfile('kalman01') section=executionProfile.Sections(2); data=section.ExecutionTimeInSeconds; histogram(data, 30,'Normalization','probability');
If the generated code contains nested functions, the execution generates pie charts that show the relative execution times of caller and called functions. To display the pie charts, click the icon for the caller function.
The following table lists the information provided in the code section profiles.
|Section||Name of function from which code is generated.|
|Maximum Execution Time||Longest time between start and end of code section.|
|Average Execution Time||Average time between start and end of code section.|
|Maximum Self Time||Maximum execution time, excluding time in child sections.|
|Average Self Time||Average execution time, excluding time in child sections.|
|Calls||Number 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.|
|Icon that you click to display pie charts that show the relative execution times of caller and called functions in the generated code.|
Visualize Task Scheduling
You can use the Simulation Data Inspector to visualize task scheduling and the
order of function calls. At the end of the execution, run the
schedule function. For more information, see Visualize Task Scheduling.