> Perhaps timeit should grow a macro-benchmark tool too? I find myself often > using timeit to time macro-benchmarks simply because it's more convenient at > the interactive interpreter than the alternatives. > > Something like this idea perhaps? > > http://preshing.com/20110924/timing-your-code-using-pythons-with-statement
I have essentially the same snippet (with the addition of being able to provide names for timers, thus allowing to have several executing in the code and knowing which is which) lying in my toolbox for a long time now, and I find it very useful. There's also an alternative approach, having a decorator that marks a function for benchmarking. David Beazley has one good example of this here: http://www.dabeaz.com/python3io/timethis.py Eli _______________________________________________ Python-Dev mailing list Python-Dev@python.org http://mail.python.org/mailman/listinfo/python-dev Unsubscribe: http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com