Python Dynamic Profiling
Robert Kern
robert.kern at gmail.com
Thu Dec 4 14:34:14 EST 2008
esgameserver at gmail.com wrote:
> Hi,
>
> Sorry for re-posting but I want to clarify my question again here.
>
> So, we have a multithreaded server application and I want to see the
> profile of our code means which function is executed how many times
> and time spent in that function dynamically. With dynamic, I mean
> without stopping the profiled thread.
>
> Is there any way to do that, other than hacking my own code with hooks
> and calculating the info above by hand?
>
> P.S:cProfile and Profile modules are very good indeed, but as far as I
> understand you need to stop the profiler and the associated thread to
> see the profile results. That is unacceptable for my situation.
Don't use the run*() methods. Instead, use enable() and disable(). This means
that the profiler isn't the thing calling your code. You can stop it and collect
the profile information without halting your code.
--
Robert Kern
"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco
More information about the Python-list
mailing list