iNTERFACEWARE Products Manual > Installing and Using Chameleon > Using Python Scripting > Debugging Python > Tracing and Profiling Python Script Execution |
|
Looking for Iguana v.5 or v.6? Learn More or see the Help Center.
If you are writing a complicated Python script, you can link to code that will trace your program execution and display the inputs to and outputs from any functions that you want to track. In addition, when a function is selected for tracing, the amount of running time used by this function is tracked. This tracking operation is known as function profiling.
To implement tracing and profiling in your Python script, use the tracing.py module, which is included in the lib/ifware subdirectory of the directory in which Chameleon is installed. The tracing library consists of the following functions:
The output from trace_history() looks something like this:
In this output, Time w/Children tracks the amount of time used by both the specified function and any functions that it calls. Time Alone measures only the time actually spent inside this function. #Calls is the number of times this function was called. Here is a very simple example of a Python script that uses the tracing.py module:
When tracing has been enabled by start_tracing(), the call to test() produces tracing information that looks something like this:
|