I am using Python's (v2.4) profile
module to profile a numpy
script, and the following entry appears to account for the bulk of the execution time:
ncalls tottime percall cumtime percall filename:lineno(function) 256/1 0.000 0.000 7.710 7.710 <string>:1(?)
Unfortunately, its appearance makes it hard to Google.
How do I go about figuring out what this is exactly?
edit The profiler is run from the shell as follows: python -m profile -s cumulative script.py
The syntax is cProfile. run(statement, filename=None, sort=-1) . You can pass python code or a function name that you want to profile as a string to the statement argument. If you want to save the output in a file, it can be passed to the filename argument.
Profiling is a technique to figure out how time is spent in a program. With these statistics, we can find the “hot spot” of a program and think about ways of improvement. Sometimes, a hot spot in an unexpected location may hint at a bug in the program as well.
The line_profiler test cases (found on GitHub) have an example of how to generate profile data from within a Python script. You have to wrap the function that you want to profile and then call the wrapper passing any desired function arguments. Also, you can add additional functions to be profiled as well.
Analysis of the profiler data is done using the Stats class. This class constructor creates an instance of a “statistics object” from a filename (or list of filenames) or from a Profile instance.
Ignore this line. It is an artifact of how the profiler is implemented. It is not telling you anything useful. Look at the "tottime" value for it: 0.000. "tottime" is the amount of time spent executing "<string>:1(?)" excluding time spent executing children of it. So, no time is spent here. "cumtime" and "percall" are large because they include time spent in children. See http://docs.python.org/library/profile.html#cProfile.run for more details.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With