On Sunday 7 Jun 2015 11:28 CEST, Steven D'Aprano wrote: > Here is a simple example: > > http://code.activestate.com/recipes/577896-benchmark-code-with-the-with-statement/ I use that now in my function: #----------------------------------------------------------------------- def time_test(function, arguments, print_time = True): t = Timer() with t: results = function(*arguments) used_time = t.interval if print_time: print('It took {0} seconds'.format(used_time)) else: results = (used_time, results) return results #-----------------------------------------------------------------------
I find that neater. It also looks like the time value is a little less, but I did not really measure it. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof -- https://mail.python.org/mailman/listinfo/python-list