Interpreting Code Profiler hits and elapsed, wait, own and total time
Key Takeaway
Total Time includes everything an artifact calls, but Own Time covers only its own code. So when a controller's Own Time is much smaller than its Total Time, most of its time goes to the script functions and API calls nested inside it.
The Code Profiler is a B2C Commerce tool that tracks run-time performance and shows which requests, scripts and methods use the most processing time. You sort its elapsed time columns by Sum to find the heaviest endpoints first, and then the specific methods worth optimizing. Comparing Own Time with Total Time tells you whether the slow part is an artifact's own code or the calls inside it.
Elapsed Time, Own Time and Total Time
You can filter Code Profiler results by Category. Category values include REQUEST for whole requests, SCRIPT_CONTROLLER for JavaScript controllers, SCRIPT_FUNCTION for JavaScript functions and SCRIPT_API for API calls.
Elapsed Time is the time spent executing an artifact. Elapsed Time has two measures.
| What it measures | |
|---|---|
| Total Time | The whole duration from the beginning to the end of the artifact's execution |
| Own Time | Only the time spent in the artifact itself, with the runtimes of the calls nested inside it subtracted |
Total Time therefore includes the time of everything the artifact calls, unlike Own Time. The gap between the two is the time spent in nested calls.
If a controller's Own Time is much smaller than its Total Time...
Most of its Total Time is the run time of the script functions and API calls nested inside it. Look at those SCRIPT_FUNCTION and SCRIPT_API entries to find the slow code.
If a controller's Own Time is close to its Total Time...
Little of its time goes to nested calls. The controller's own code is where the time goes.
In the elapsed time results, a custom Loyalty-Summary controller shows a Total Time of 900 ms and an Own Time of 60 ms. Subtracting leaves 840 ms, so about 93 percent of the controller's time ran inside the functions and API calls it made. Rewriting the controller's own lines could save at most 60 ms. The SCRIPT_API and SCRIPT_FUNCTION entries it calls hold the other 840 ms, so those entries are where to look.