Keil Logo

PerformanceAnalyze

The PerformanceAnalyze (PA) command gathers execution statistics (execution time and number of calls) about the application or parts of the application, and can be used to tune the application for maximum performance. The result can be viewed in the windows Command and Performance Analyzer.

Note

  • Applications should be compiled with full debug information to best support performance analysis. Enable Options for Target - Output - Debug Information.

PerformanceAnalyze for Cortex-M and ARM Architectures

ARM architectures need no specific setup.

For Cortex-M architectures configure the device as described in the ULINKpro User's Guide, chapter Configure Cortex-M Devices for Tracing.

The table lists the command options for Cortex-M and ARM architectures:

Syntax Description
PA Displays code execution statistics (execution time and number of calls). Execution time is calculated in [µs]. The result is displayed in two blocks. The first block is sorted by the execution time spent in a function. The second block is grouped by modules and functions, without a specific order.
PA RESET Resets all statistics.
Examples

The example shows a possible result of the PA command executed for a Blinky project.

PA
Time spent in code without debug info - Time:   10.357 µs (0%)
Functions sorted by execution time consumption:
  'main' - Time:  939.367 ms (100%), Calls: 1
  'SystemInit' - Time:   44.881 µs (0%), Calls: 1
  'SysTick_Handler' - Time:   13.190 µs (0%), Calls: 93
  'GPIO_PortClock' - Time:    3.756 µs (0%), Calls: 8
  'GPIO_PinConfigure' - Time:    2.905 µs (0%), Calls: 8
  'LED_Initialize' - Time:    1.256 µs (0%), Calls: 1
  'Reset_Handler' - Time:    0.167 µs (0%), Calls: 1
  'LED_On' - Time:    0.119 µs (0%), Calls: 10
  'LED_Off' - Time:    0.107 µs (0%), Calls: 9
  'LED_Num' - Time:    0.060 µs (0%), Calls: 1
  'BusFault_Handler' - Time: 0 µs (0%), Calls: 0
  'SVC_Handler' - Time: 0 µs (0%), Calls: 0
  'PendSV_Handler' - Time: 0 µs (0%), Calls: 0
  'Default_Handler' - Time: 0 µs (0%), Calls: 0
  'SysTick_Handler' - Time: 0 µs (0%), Calls: 0
  'DebugMon_Handler' - Time: 0 µs (0%), Calls: 0
  'UsageFault_Handler' - Time: 0 µs (0%), Calls: 0
  'MemManage_Handler' - Time: 0 µs (0%), Calls: 0
  'HardFault_Handler' - Time: 0 µs (0%), Calls: 0
  'NMI_Handler' - Time: 0 µs (0%), Calls: 0

Execution times by Modules and Functions:
App: 'Blinky', Time:  939.433 ms (100%)
 Module: 'RTE/Device/.../startup_<device>.s', Time:    0.167 µs (0%)
  Function: 'Reset_Handler', Time:    0.167 µs (0%), Calls: 1
  Function: 'NMI_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'HardFault_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'MemManage_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'BusFault_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'UsageFault_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'SVC_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'DebugMon_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'PendSV_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'SysTick_Handler', Time: 0 µs (0%), Calls: 0
  Function: 'Default_Handler', Time: 0 µs (0%), Calls: 0
 Module: 'C:/MDK5/ARM/PACK/.../GPIO_template.c', Time:    6.661 µs (0%)
  Function: 'GPIO_PortClock', Time:    3.756 µs (0%), Calls: 8
  Function: 'GPIO_PinConfigure', Time:    2.905 µs (0%), Calls: 8
 Module: 'RTE/Device/.../system_<device>.c', Time:   44.881 µs (0%)
  Function: 'SystemInit', Time:   44.881 µs (0%), Calls: 1
 Module: 'C:/.../LED.c', Time:    1.542 µs (0%)
  Function: 'LED_Initialize', Time:    1.256 µs (0%), Calls: 1
  Function: 'LED_On', Time:    0.119 µs (0%), Calls: 10
  Function: 'LED_Off', Time:    0.107 µs (0%), Calls: 9
  Function: 'LED_Num', Time:    0.060 µs (0%), Calls: 1
 Module: 'Blinky.c', Time:  939.380 ms (100%)
  Function: 'SysTick_Handler', Time:   13.190 µs (0%), Calls: 93
  Function: 'main', Time:  939.367 ms (100%), Calls: 1

Note

  • Performance analysis address ranges must have unique entry and exit points and may not include an intermediate return (RET) instruction.
  • A new address range may not overlap an existing range.
Examples
>PA main                         /* Define a range for main()   */
>PA timer0                       /* Define a range for timer0() */
>PA clear_records                /* Define more ranges          */
>PA measure_display
>PA save_current_measurements
>PA read_index
>PA set_time
>PA set_interval
>
>PA                              /* display all PA ranges       */
  0: main: (FF01EF-FF03B6)       /* FF01EF = C:0x01EF           */
  1: timer0: (FF006A-FF0135)
  2: clear_records: (FF01C0-FF01EE)
  3: measure_display: (FF07E7-FF084A)
  4: save_current_measurements: (FF000E-FF0069)
  5: read_index: (FF0136-FF01BF)
  6: set_time: (FF084B-FF08CA)
  7: set_interval: (FF08CB-FF09A5)

/* After execution of the user program ... */

>PA                              /* Display ranges and stats   */
  0: main: (FF01EF-FF03B6)
     count=1, min=-1, max=0, total=167589
  1: timer0: (FF006A-FF0135)
     count=2828, min=33, max=254, total=226651
  2: clear_records: (FF01C0-FF01EE)
     count=1, min=27086, max=27086, total=27086
  3: measure_display: (FF07E7-FF084A)
     count=10, min=19495, max=19503, total=185027
  4: save_current_measurements: (FF000E-FF0069)
     count=491, min=205, max=209, total=100665
  5: read_index: (FF0136-FF01BF)
  6: set_time: (FF084B-FF08CA)
  7: set_interval: (FF08CB-FF09A5)
>
>PA KILL 7                       /* Remove set_interval        */
>PA KILL 6                       /* Remove set_time            */
>PA KILL 5                       /* Remove read_index          */
>PA
  0: main: (FF01EF-FF03B6)
     count=1, min=-1, max=0, total=167589
  1: timer0: (FF006A-FF0135)
     count=2828, min=33, max=254, total=226651
  2: clear_records: (FF01C0-FF01EE)
     count=1, min=27086, max=27086, total=27086
  3: measure_display: (FF07E7-FF084A)
     count=10, min=19495, max=19503, total=185027
  4: save_current_measurements: (FF000E-FF0069)
     count=491, min=205, max=209, total=100665
>
>PA RESET                        /* Clear all recorded information */
>PA
  0: main: (FF01EF-FF03B6)
  1: timer0: (FF006A-FF0135)
  2: clear_records: (FF01C0-FF01EE)
  3: measure_display: (FF07E7-FF084A)
  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.