main content

analyze execution-凯发k8网页登录

analyze execution-time and stack usage profiles for generated code

since r2023a

description

use the code profile analyzer to analyze execution-time and stack usage profiles produced by software-in-the-loop (sil) or processor-in-the-loop (pil) execution of generated code.

you can:

  • view execution times of tasks and functions, visualize the function-call stack at a specific simulation time, and compare execution times from different runs.

  • view stack usage for tasks and functions and compare values from different runs.

you can also use the code profile analyzer to analyze execution-time profiles produced by xcp-based external mode simulations.

open the code profile analyzer app

if you are generating code for a simulink® model, click the sil/pil tab. in the results gallery, under execution profiling results or stack profiling results, click the code profile analyzer button.

if you are generating code for matlab® code, terminate the sil/pil execution in the command window or in the test output tab in the matlab coder™ app. the code generator produces a message in the command window that contains a link to the execution or stack profiling report. click that link.

alternatively, for both simulink and matlab code generation, open the code profile analyzer from the command window after the sil/pil execution has been terminated by entering coder.profile.show or coder.profile.show(profilevariable).

for simulink code generation, profilevariable is a workspace variable that you specify through the workspace variable (codeexecutionprofilevariable) or stack workspace variable (codestackprofilevariable) configuration parameter.

for matlab code generation, obtain profilevariable by using the or getcoderstackprofile function.

examples

this workflow shows the steps you might use when analyzing execution-time metrics with the code profile analyzer.

  1. open the code profile analyzer.

  2. in the import section, from the import results drop-down list, select the time profiling workspace variable that contains your execution-time measurements.

  3. in the settings section, specify values for:

    • time unit — unit for displayed time measurements

    • cpu clock (hz) — cpu frequency for analysis

  4. to perform an execution-time analysis, in the analysis section, click one of these buttons:

    • task execution — analyze task execution times.

    • function execution — analyze task and function execution times.

    • function-call stack — visualize the function-call stack at a specific simulation time

    • comparison — compare execution times from two simulations

  5. select a code section (a task or function), and then, in the results section, click one of these buttons:

    • highlight source — in the simulink model, show the block associated with the code section.

    • highlight code — in the generated code, show the call to the code section.

    • generate distribution — display the execution-time distribution for the code section.

    • function distribution — display pie charts that show the relative execution times of the caller and called functions in the generated code.

    • export to sdi — display the measured execution times in the simulation data inspector.

  6. for the overall simulation, use the results section to:

    • highlight profiling — color model components that are profiled.

    • open report — open the code execution profiling report.

    • generate schedule — visualize task scheduling.

    for more information, see .

this workflow shows the steps you might use when analyzing stack usage metrics with the code profile analyzer.

  1. open the code profile analyzer.

  2. in the import section, from the import results drop-down list, select a memory profiling workspace variable that contains your stack usage measurements.

  3. to perform a stack usage analysis, in the analysis section, click one of these buttons:

    • stack memory — analyze stack usage of tasks and functions

    • comparison — compare stack usage measurements from two simulations

  4. select a code section (a task or function), and then, in the results section, click one of these buttons:

    • highlight code — show call to code section in generated code.

    • generate distribution — display execution memory distribution for code section.

    • export to sdi — display stack usage values in simulation data inspector.

  5. for the overall simulation, use the results section to:

    • open model — open the source model.

    • open report — open the code stack profiling report.

    for more information, see .

related examples

    version history

    introduced in r2023a

    网站地图