How to Profile Python Code

posted October 18th 2008 at 0534 EDT in All, Python, Web

I have been doing some Google App Engine development, and I happened across this block of code which quite possibly outputs the best per-page load python performance statistics that I’ve ever seen.

http://code.google.com/appengine/kb/commontasks.html#profiling

It doesn’t get better than that. Here is a sample snippet from the output

387856 function calls (383171 primitive calls) in 0.725 CPU seconds

Ordered by: internal time
List reduced from 802 to 120 due to restriction <120>

ncalls  tottime  percall  cumtime  percall filename:lineno(function)
94    0.119    0.001    0.119    0.001 {built-in method __new__ of type object at 0x1f19a0}
28731    0.051    0.000    0.066    0.000 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/net/proto/ProtocolBuffer.py:295(putVarUint64)
28731    0.040    0.000    0.106    0.000 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/net/proto/ProtocolBuffer.py:287(putVarInt64)
28053    0.040    0.000    0.138    0.000 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/net/proto/ProtocolBuffer.py:281(putVarInt32)
5220    0.018    0.000    0.049    0.000 /Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/net/proto/ProtocolBuffer.py:328(putPrefixedString)

One Response

  1. [...] How to Profile Python Code I have been doing some Google App Engine development, and I happened across this block of code which quite possibly outputs the best per-page load python performance statistics that I’ve ever seen. via Views: 0 Comments: 1 Posted on : elbandito on 22 August, 2008 10:38:22 Daca ai vazut un comentariu pe care il crezi neadecvat (ex. injuri, rasism , nu are legatura cu subiectul ) , te rugam apasa pe “Reporteaza abuz” din coltul dreapta jos al mesajului Astfel vei anunta moderatorul ca un mesaj neadecvat a fost publicat. Moderatorul il va verifica si probabil bana utilizatorul care l-a postat. Atentie : daca nu il reportezi , noi probabil nu il vom vedea. So use this feature and the message boards will be a better place for everyone! Start « Previous PageNext Page » End [...]