Refining this result from the pstats module

I ran cProfile in my code, and this is the result:

% stats 10
     646493 function calls (524209 primitive calls) in 3.606 CPU seconds

Ordered by: cumulative time
List reduced from 260 to 10 due to restriction <10>

ncalls   tottime  percall  cumtime  percall filename:lineno(function)
     1     0.000    0.000    3.606    3.606 <string>:1(<module>)
     1     0.007    0.007    3.606    3.606 {execfile}
     1     0.068    0.068    3.599    3.599 example.py:7(<module>)
     3     0.000    0.000    3.266    1.089 tree.py:1058(parseString)
6698/3     0.068    0.000    3.244    1.081 tree.py:2406(do_parse3)
104813/3   1.084    0.000    3.244    1.081 tree.py:926(_nocache)
2615/3     0.016    0.000    3.243    1.081 tree.py:2679(internal_parse)
3602/14    0.712    0.000    3.239    0.231 tree.py:2531(do_parse2)
  13/8     0.000    0.000    3.229    0.404 tree.py:2876(do_parse)
2546/20    0.024    0.000    3.218    0.161 tree.py:1003(parse)

In documents

We define a primitive to mean that the call was not called by recursion

Can I then conclude with certainty that the reasons why my code is slow are as follows:

  • due to recursive calls 122284.
  • The biggest recursive methods: do_parse3and _nocache.
  • Primitive calls are irrelevant and cannot be further optimized.
+3
source share
1 answer
  • I think you cannot see if the time was wasted due to method calls or because of the work done inside this method.

  • . - python. , .

  • . , , , , , . ; , , () . , () -, , .

? Gprof2Dot :

gprof2dot.py -f pstats tmp.pstats | dot -Tpng -o tmp.png

http://code.google.com/p/jrfonseca/wiki/Gprof2Dot
http://maxy.homeip.net/misc/gprof2dot_example.png

+2
source

All Articles