Execution Time
Measures execution time and number of calls for various callable entities of your code
Since R2023b
Description
The execution time measures various dynamic metrics such as:
Time required to execute different callable entities: To calculate this result, Polyspace® Test™ initiates a timer when the test executable starts its operation. Say a function is called at time when the timer value is
T_entryand the function returns when the timer value isT_return. Then theExecution Timemetric of the function is calculated using these values.Number of calls: Polyspace Test reports how many times a callable entity is called in your code.
Polyspace Implementation
When you calculate execution time, Polyspace Test instruments your source code to calculate the number of calls to functions and their execution time. If your code calls a function more than once, Polyspace Test reports an average execution time for the function. When calculating the execution time of the functions, Polyspace Test calculates several different metrics:
Total time— The total time to execute a function from its entry point to when the function returns. That is,Total time = T_return - T_entry
Self time— This metric shows the time required to execute a function from entry point to return without considering the time required to execute the callee functions. For instance, say the functionfoo()calls the functionbar()twice. TheTotal timeforfoo()isT_fooand theTotal timeforbar()isT_bar. Then, Polyspace Test calculates theSelf timeoffoo()as:T_self_foo = T_foo-2*T_bar
Count— Represents the number of times a function executes.Max— The maximum calculatedSelf timefor a function.Saturated— A binary flag representing whether theTotal timefor a function overflows a 32 bit counter. For a particular function call, if the total time value saturates, Polyspace sets:The
Saturatedflag totrueMaxto the saturated valueThe
Total timeandSelf timeto the last known unsaturated value
When instrumenting your source code for execution profile calculation, Polyspace Test injects various macros. These macros can hinder some compiler optimizations, such as inlining trivial functions. If compiler optimizations are prevented, the reported execution time is an upper bound of the optimized execution time.
Polyspace Test does not support calculating more than one of the code coverage, execution time, and memory use metrics at a time.
Examples
Version History
Introduced in R2023b