[IronPython] More Performance comparisons - dictionary updates and tuples

Michael Foord fuzzyman at voidspace.org.uk
Wed Apr 16 20:09:25 CEST 2008


Simon Dahlbacka wrote:
>
>     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."

Sure - DateTime has a granularity of 10-15ms, which I thought was 
accurate enough for this.

Thanks
Michael


>
> 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
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>   




More information about the Ironpython-users mailing list