> from random import random
>
> try:
> import clr
> from System import DateTime
>
> def timeit(func):
> start = DateTime.Now
> func()
> end = DateTime.Now
> print func.__name__, 'took %s ms' % (end - start).TotalMilliseconds
Just a small nitpick or whatever, you might want to consider using the
System.Diagnostics.StopWatch class as it "Provides a set of methods and
properties that you can use to accurately measure elapsed time."
i.e.
try:
import clr
from System.Diagnostics import StopWatch
def timeit(func):
watch = StopWatch()
watch.Start()
func()
watch.Stop()
print func.__name__, 'took %s ms' % watch.Elapsed.TotalMilliseconds
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com