I've written up some code and stuck it in the yt branch of the hg repo. The changeset is here:
So far it's kind of rudimentary, but it exposes two functions for decorating. The slightly more sophisticated example you have proposed would be better handled through an extension to the logging module, which would require adding a new filter and a new loglevel to the yt/logger.py module. You could then have it transparently call the yt_counters object as necessary.
Here's a script to demonstrate the simple stuff I put in:
It would also be nice to hook into atexit to have it print these on exit:
On Sat, Jul 25, 2009 at 1:31 PM, Stephen Skorystephenskory@yahoo.com wrote:
What do we think is the best way to go about adding a very basic benchmarking tool to yt?
Right now my thought is to simply add to mylog 'benchmark'. For each part you wanted to benchmark you'd wrap it with two statements:
mylog.benchmark('start complicated mess') ... mylog.benchmark('end complicated mess')
Instead of printing this to stderr/out, it would go to a standard file, or something that could be easily analyzed by a simple function. The nice thing about using mylog is Matt has already got processor labels working, and it has timestamps. It would be therefore also trivial to have nested benchmarked sections, etc...
Thanks for your comments!
firstname.lastname@example.org o__ Stephen Skory http://physics.ucsd.edu/~sskory/ _.>/ _Graduate Student ________________________________(_)_(_)_______________
Yt-dev mailing list Ytemail@example.com http://lists.spacepope.org/listinfo.cgi/yt-dev-spacepope.org