Suppose it had an infinite loop. How would you find it?
I imagine you would just pause it in the debugger and look at the code at the various levels of the stack, because you know the loop is somewhere on the stack. Right?
Suppose the loop isn't infinite, merely taking a long time. Is that much different?
No matter what the problem is, if it is costing you some percent of time, like 90%, or 50%, or 20%, that's the probability you will catch it in the act when you pause it. So if you pause it several times, you're going to see it. The worse it is, the fewer times you have to pause it and look. It will be obvious.
So forget about timing. Just find out what it's doing.
In response to question, here is some mod_python doc:
5.4.1 PythonEnablePdb Syntax:
PythonEnablePdb {On, Off}
Default: PythonEnablePdb Off
Context: server
config, virtual host, directory,
htaccess Override: not None Module:
mod python.c When On, mod python will
execute the handler functions within
the Python debugger pdb using the
pdb.runcall() function. Because pdb is
an interactive tool, start httpd from
the command line with the -DONE
PROCESS option when using this
directive. As soon as your handler
code is entered, you will see a Pdb
prompt allowing you to step through
the code and examine variables.
5.4.2 PythonDebug Syntax:
PythonDebug {On, Off} Default: PythonDebug Off
Context: server config, virtual host,
directory, htaccess Override: not None
Module: mod python.c Normally, the
traceback output resulting from
uncaught Python errors is sent to the
error log. With PythonDebug On
directive specified, the output will
be sent to the client (as well as the
log), except when the error is IOError
while writing, in which case it will
go to the error log. This directive is
very useful during the development
process. It is recommended that you do
not use it production environment as
it may reveal to the client
unintended, possibly sensitive
security information.