Closed robbyt closed 11 years ago
I might be confused on how to use Plop, Based on the example in your demo file, you instantiate a plop collector only in the get and subsequent callback. Should plop be added to the lowest level of the application? (the equivalent of the main() ) or can it be used for profiling single functions?
The collector is instantiated in the ProfileHandler, but it's collecting data on everything else that's happening at the same time (i.e. generate_traffic and HelloHandler). Plop is designed for profiling servers, where it can be switched on for a minute or so at a time during a long-running process, as seen in the demo. It's possible to profile a "single function" as long as that function runs for a long time, but in most cases it probably makes the most sense to profile the equivalent of main(), which can be done with "python -m plop.collector myscript.py".
Sampling profilers take enough time (tens of seconds) to collect a useful amount of data that I'm not sure decorating a single function is a useful way to collect data. There are also thread-safety issues, etc since the collector uses signal handlers which are a process-wide state. You're welcome to use something like this in your own projects if it suits your needs, but for general use I'd recommend thinking about things in terms of sampling the entire process and then narrowing down to a single function by filtering at the viewer level.