You should probably at least use a recognized python test suite like
pystones or richards, or use some real world applications for this.
look at the benchmarks for the pypy project for example: http://tuatara.cs.uni-duesseldorf.de/benchmark.html
Good luck on you endeavor
On Jan 24, 2009, at 2:45 AM, joe wrote:
Ok, I ran a little test script through CodeAnalyst. basically it is just a loop that does member lookups and function calls (this is in py2.5 btw, will have to install 3.x and test that too).
The results were kindof interesting. CodeAnalyst is sample-based, so I don't know if it's completely reliable. It is usually reasonably correct though.
Much of the time was spent in PyEval_EvalFrameEx (which makes sense, it being the code that interprets and executes the bytecode). 14633 samples were spent in it, of which around 2000 were spent in what appears to be the switch jump lookup (I'm not sure, I'm not the best at reading assembly code). After PyEval_EvalFrameEx, the four next most expensive calls were PyWrapper_New (at 2879 samples) PyInstance_New (at 1418) PyDict_GetItem (at 1298 samples) and PyObject_SetAttr (at 1155).
Here's the (rather hastily thrown together) script:
t = 0
class Bleh: a = 0 b = 0 c = 0
def __init__(self): self.a = A() self.b =  self.c = ""
def doit(self, no=0): if no: return
while 1: a = self.a b = self.b c = self.c self.a = a self.b = b self.c = c self.doit(1) b = Bleh() b.doit()
So, it looks like indirect or direct threading could help (if I'm reading the results and asm code right). Also the attribute lookups did appear to take a significant portion of the time, as did PyInstance_New and PyWrapper_New (need to look up what those last two do). This is just preliminary though, that isn't a particularly good script for profiling, I suspect.
-- Leonardo Santagada santagada at gmail.com