Profiling with DSS
From Texas Instruments Embedded Processors Wiki
Contents |
Overview
Debug Server Scripting (DSS) provides several APIs to setup, collect and export profiling data.
Environment Setup
The environment setup needed is the same as for any DSS script.
Profile Setup
To setup profiling, a profile activity object for each desired activity needs to be created using the profileSetup.getActivity() API. A default activity to profile must be passed into the API. There are currently three default activities supported:
- Collect Code Coverage and Exclusive Profile Data - this will configure the profiler to collect code coverage data
- Profile all Functions for CPU Cycles - this will configure the profiler to collect CPU cycles (cycle.CPU) for all functions
- Profile all Functions for Total Cycles - this will configure the profiler to collect total cycles (cycle.total) for all functions
Note that the activities available can vary depending on the target. The list of supported activities for a particular target can be generated with the profileSetup.printActivityList() API.
To create and enable a profile activity object for profiling all functions for Total cycles:
// retrieve an activity from the activity list based on the name myProfileActivity = debugSession.profileSetup.getActivity("Profile all Functions for Total Cycles"); // enable profiling for specified activity myProfileActivity.setStatus(true);
Once an activity object is created, it can be further configured to collect data for more events than just the default event. This can be done by getting a property object for the event to be profiled from the activity interface, and then enabling it. The following example will add the collection of L1P cache misses to the events being profiled:
// get the propery object for L1P miss summary eventL1PMissSummary = myProfileActivity.getProperty("Events.L1P.miss.summary"); // enable collection L1P miss summary data eventL1PMissSummary.setBoolean(true);
If you wish to profile many events, you can create an array of the desired events and then use a 'for' loop for a cleaner implementation:
// array of events to be profiled var evtNames = new Array("Events.L1D.hit.summary", "Events.L1D.miss.summary", "Events.L1D.miss.conflict", "Events.L1D.miss.non_conflict", "Events.L1P.miss.summary", "Events.CPU.stall.mem.L1D", "Events.CPU.stall.mem.L1P", "Events.L1P.hit" ); // retrieve an activity from the activity list based on the name myProfileActivity= debugSession.profileSetup.getActivity("Profile all Functions for Total Cycles"); // enable profiling of all events in the array for (evtCount=0;evtCount<evtNames.length;evtCount++) { event = myProfileActivity.getProperty(evtNames[evtCount]); event.setBoolean(true); } // enable profiling for specified activity myProfileActivity.setStatus(true);
Note that the available events to profile will vary depending on the device and if simulation or emulation is being used. The profile activity listProperties() API will generate the full list of all events supported for the current device.
Exporting Profiling Data
The exporting of the collected profiling data is done with DVT. Note that the API doc for exporting profiling data is in a different location than the main DSS documentation (<Install Dir>\ccsv4\dvt\scripting\docs\API)
Since exporting the data is done by DVT, a DVT server needs to be created. Note that a DVT server must be created sometime AFTER profile setup and enable is completed.
dvtServer = dssScriptEnv.getServer("DVTServer.1");
Then a profile analysis session must be created to export the data.
// create a profile analysis session for function level profiling data collected var profileAnalysisSession = dvtServer.openProfileAnalysisSession(debugSession, "FunctionProfile");
Before exporting any data, we need to make sure that all processing of profiling data is completed:
profileAnalysisSession.waitUntilProfilingComplete();
Next create a ProfileAnalysisExport object for all tables of collected profiling data
var exports = profileAnalysisSession.exportData();
We can then export the data. We can choose to export some or all of the data. The example below will use the API to export all the data for the first table into a *.csv file.
exports[0].save("myProfilingData.csv");
When exporting multiple tables (a table exists for each event enabled), a 'for' loop can be used:
for (var e=0; e < exports.length; e++) { exports[e].save(profileResultsFolder + "\\" + exports[e].getName() + ".csv"); }
Once done, don't forget to terminate the profile session and terminate the DVT Server:
// close profile session profileAnalysisSession.terminate(); dvtServer.stop();
Comments
Comments on Profiling with DSS


Hi,
i'm trying to export the Profiling data by Perl script. and it actually works by the way this page provided. but i want to know if there is any method to get the line coverage?
--Randyn 21:17, 20 February 2010 (CST)