Michael Spencer wrote:
Anyway, here are the revised timings...
... print shell.timefunc(func_translate1, "Bob Carol Ted Alice" * multiplier, 'adB')
What is shell.timefunc?
This snippet, which I attach to my interactive shell, since I find timeit awkward to use in that context:
def _get_timer(): if sys.platform == "win32": return time.clock else: return time.time return
def timefunc(func, *args, **kwds): timer = _get_timer() count, totaltime = 0, 0 while totaltime < 0.5: t1 = timer() res = func(*args, **kwds) t2 = timer() totaltime += (t2-t1) count += 1 if count > 1000: unit = "usec" timeper = totaltime * 1000000 / count else: unit = "msec" timeper = totaltime * 1000 / count return "%s(...) %s iterations, %.2f%s per call" % \ (func.__name__, count, timeper, unit)
Michael
-- http://mail.python.org/mailman/listinfo/python-list