Pstats Profiling questions

I know we can track the performance of blocks of code by making our own Pstats collecter. However is there a way to track how long it tacks to render a certain object? Like if I have a bunch or teapots and a bunch of bananas, is there a way to tell pstats to tell how much time it spent rendering teapots and how much on bananas? Josh thinks its probably hidden in the Attrib interface. If there isnt a way to do this using pstats is there a general tip for doing this?

That’s not as simple a question as it seems.

Drawing an object has three steps: (1) discovering the object in the scene graph, and setting it up for rendering (2) setting the state commands for the object, and issuing the glDrawElements() call for the object (3) actually drawing it onscreen.

Step (1) occurs in the “cull” traversal. Step (2) occurs in the “draw” traversal. Both of these can be timed in Panda, but since there are usually hundreds or thousands of objects in a scene, it may be difficult to extract out just the one object you are interested in. There is a place to put the calipers for this, though.

But neither of them has much to do with the actual time of “drawing” the object as we normally think of it. Step (3) may be the most interesting time, but it occurs on the graphics card and is very difficult or impossible to measure on the CPU.

David