[IronPython] More Performance comparisons - dictionary updates and tuples

Simon Dahlbacka simon.dahlbacka at gmail.com
Wed Apr 16 20:01:14 CEST 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."


   import clr
   from System.Diagnostics import StopWatch

   def timeit(func):
       watch = StopWatch()
       print func.__name__, 'took %s ms' % watch.Elapsed.TotalMilliseconds
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080416/5ef42ae7/attachment.html>

More information about the Ironpython-users mailing list