profile - Code execution profile and stack usage information

Syntax

ps=profile(cc,'execution','format',timeout)
ps=profile(cc, 'execution','format')
ps=profile(cc)
profile(cc,'stack',action)

Description

ps=profile(cc,'execution','format',timeout) returns execution profile measurements from the generated code. Structure ps contains the information in either raw form or filtered and formatted into fields. STS objects are a service provided by the DSP/BIOS real-time kernel that can help you profile and track the way your code runs. For details about STS objects and DSP/BIOS™, refer to your Texas Instruments™ documentation that came with CCS IDE.

To let you to define how to return the profiling information, profile supports three formatting options for the profiling report and data. You define the report format by setting the format input argument.

format StringDescription

raw

Returns an unformatted list of the timing objects information. Returns and formats all time-based objects.

report

Returns the same data as the raw option, formatted into an HTML report. Works only on projects that include DSP/BIOS. If you own Target Support Package™ TC6 software, profile(cc,'report') provides more information about code you generate from Simulink® software models, using data from the STS objects that are part of DSP/BIOS instrumentation. Refer to "Profiling Code" in your Target Support Package TC6 documentation for more information.

tic

Returns a formatted list of the STS timing objects information. Filters out some of the information returned with the raw option. To be returned by this format, the object must be time-based. Does not return user-defined objects. Use raw to see user-defined objects.

The reporting formats you can use depend on the source of your project and whether you use DSP/BIOS, as shown in the next table:

Project SourceProject Has DSP/BIOS?Valid format OptionsAdditional Product Required?
Stand alone codeYesraw, tic, reportNo
NoNoneNot Applicable
Project code generated from Simulink modelYesraw, tic, reportYes—Target Support Package TC6 to use the report format
NoreportNo

When you choose raw, variable ps contains an undocumented list of the information provided by CCS IDE. The tic option provides the same information in ps, as a collection of fields.

Fields in psDescription

ps.cpuload

Execution time in percent of total time spent out of the idle task.

ps.sts

Vector of defined STS objects in the project.

ps.sts(n).name

User-defined name for an STS object sts(n). Value for n ranges from 1 to the number of defined STS objects.

ps.sts(n).units

Either Hi Time or Low Time. Describes the timer applied by this STS object, whether high- or low- resolution time based.

ps,sts(n).max

Maximum measured profile period for sts(n), in seconds.

ps.sts(n).avg

Average measured profile period for sts(n), in seconds.

ps.sts(n).count

Number of STS measurements taken while executing the program.

With projects that you generate that use DSP/BIOS, the report option creates a report that contains all of the information provided by the other options, plus additional data that comes from DSP/BIOS instrumentation in the project. You enable the DSP/BIOS report capability with the Profile performance at atomic subsystem boundaries option on the Target Support Package C6 option on the Real-Time Workshop pane of the Simulink Configuration Parameters dialog box.

ps=profile(cc, 'execution','format') defaults to the time-out period specified in the ticcs object cc.

ps=profile(cc) returns the task execution profile information in ps as a formatted structure of fields (same as 'report.'

profile(cc,'stack',action) returns the CPU stack usage from your application. action defines the stack use profile operation and accepts one of the strings in the following table:

action StringDescription
setupInitializes the CPU stack with a set of known patterns—A5 on C6000 processors. A5A5 on C2000 and C5000 processors.
reportReturns the report of the stack usage from running your application.

You cannot assign the stack profile report to an output variable.

For more information about using stack profiling, refer to System Stack Profiling.

Examples

You use profile to view information about your application running on your processor. This example presents both forms of the data returned by profile. Open and build one of the DSP/BIOS-enabled projects from the TI DSP/BIOS Tutorial Module, such as volume.pjt located in the folder ti\tutorial\target\volume2. When you specify the project to open, enter the full path name to the project file.

cc=ticcs;
% ccsroot is your CCS install directory.
open(cc,'ccsroot\tutorial\sim62xx\volume2\volume.pjt');
build(cc,'all')

In CCS IDE, open the file volume.cdb that contains the DSP/BIOS configuration. Review the settings for the existing CLK and STS objects already in place in the project. For details about STS and CLK objects, refer to your TI documentation.

When you use profile, the task execution information returned comes from these objects. Make any changes you require and save the DSP/BIOS configuration file. Now rebuild your project, either in CCS IDE or from MATLAB® software, then load the file volume.out generated by the build process. If you get a time-out error, add the timeout option to the build command, specifying a long time-out period, such as 60 seconds. Often, when you receive the time out error the build has been completed successfully.

build(cc,'all')
load(cc,'..\tutorial\sim62xx\volume1\debug\volume.out')

With the project built and loaded, run your program.

run(cc) % Assumes that volume1 is the active project.

Running profile returns structure ps containing STS and CLK information that DSP/BIOS gathered while your program ran. Stop the running program before you request the profile data.

halt(cc)
ps=profile(cc,'execution')

ps = 

    cpuload: 0
        obj: [3x1 struct]

ps.obj(1)

ans = 

     name: 'KNL_swi'
    units: 'Hi Time'
      max: 1.1759e-005
      avg: 2.7597e-006
    count: 29

for k=1:length(ps.obj),disp(k),disp(ps.obj(k)),end;
     1

     name: 'KNL_swi'
    units: 'Hi Time'
      max: 1.1759e-005
      avg: 2.7597e-006
    count: 29

     2

     name: 'processing_SWI'
    units: 'Hi Time'
      max: 1.1489e-005
      avg: 1.1474e-005
    count: 2

     3

     name: 'TSK_idle'
    units: 'Hi Time'
      max: -16.1465
      avg: 0
    count: 0

Omitting the format option caused profile to return the data fully formatted and slightly filtered. Adding the raw option to profile returns the same information without filtering any of the returned data.

ps=profile(cc,'execution','raw')

ps = 

      cpuload: 0
        error: 0
    avgperiod: 1000
         rate: 1000
          obj: [4x1 struct]

for k=1:length(ps.obj),disp(k),disp(ps.obj(k)),end;
     1

        name: 'KNL_swi'
       units: 'Hi Time'
         max: 1564
       total: 10644
         avg: 367.0345
    pdfactor: 0.0075
       count: 29

     2

        name: 'processing_SWI'
       units: 'Hi Time'
         max: 1528
       total: 3052
         avg: 1526
    pdfactor: 0.0075
       count: 2

     3

        name: 'TSK_idle'
       units: 'Hi Time'
         max: -2.1475e+009
       total: 0
         avg: 0
    pdfactor: 0.0075
       count: 0

     4

        name: 'IDL_busyObj'
       units: 'User Def'
         max: -2.1475e+009
       total: 0
         avg: 0
    pdfactor: 0
       count: 0

Your results can differ from this example depending on your computer and target. In the raw format data in this example, one extra timing object appears—IDL_busyObj. As defined in the .cdb file, this is not a time based object (Units is 'User Def') and is not returned by specifying tic as the format option in profile.

See Also

ticcs

  


 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS
 © 1984-2008- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS