[IronPython] More Performance comparisons - dictionary updates and tuples
Simon Dahlbacka
simon.dahlbacka at gmail.com
Wed Apr 16 11:01:14 PDT 2008
> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ironpython.com/pipermail/users-ironpython.com/attachments/20080416/5ef42ae7/attachment.htm
More information about the Users
mailing list