[IronPython] Looping in IronPython - should it be linear?

Dave Fugate dfugate at microsoft.com
Thu Feb 15 09:34:33 PST 2007


Try replacing "range" with "xrange" and I think your performance results will change a bit (depending on the size of loopIterationValue of course).

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Steve Chadwick
Sent: Thursday, February 15, 2007 5:12 AM
To: 'Discussion of IronPython'
Subject: Re: [IronPython] Looping in IronPython - should it be linear?

Sorry - here is the code that I am using to generate the loop time.


    def RunExperiment1(self, loopInterationValue): #counting up
        print "Exp 1: Counting Up, the loop value is ",
str(loopInterationValue), "\n"
        for i in range(0, self.m_ExpRuns):
            outer_loop = 5
            # Start block of interest
            start_time = time.time()
            for j in range(0,outer_loop):
                for k in range(0, loopInterationValue):
                    1 #empty loop
            end_time = time.time()
            mean = (end_time - start_time)/(outer_loop*1.0)
            # End block of interest

            # Write output via the base class (assign to mod variables)
            self.m_Mean         = mean
            self.m_label_desc   = "Loop_Counting_Up"
            self.m_LabelValue   = loopInterationValue
            self.write_results()  #via base class

-----Original Message-----
From: users-bounces at lists.ironpython.com
[mailto:users-bounces at lists.ironpython.com] On Behalf Of Robert Wierschke
Sent: Thursday, February 15, 2007 1:37 AM
To: Discussion of IronPython
Subject: Re: [IronPython] Looping in IronPython - should it be linear?

Please post the code of your loop.

Do you instantiate objectn in your loop? I guess the memory management /
garbage collection is responsible for the additional required time.

Also the code runs in the .NET VM and the VM might do other things as well
(JIT compilation, ...).


-------- Original-Nachricht --------
Datum: Wed, 14 Feb 2007 20:43:36 -0700
Von: "Steve Chadwick" <steve.chadwick at gmail.com>
An: "\'Discussion of IronPython\'" <users at lists.ironpython.com>
CC:
Betreff: [IronPython] Looping in IronPython - should it be linear?

> All,
>         I am new to IP, and I have a silly post.  I am sure that
> someone might be able to help me understand what is happening here (I
> am truly impressed with the technical depth of this forum).  In trying
> to learn the language, one of the things I do is just run a quick
> looping experiment and measure the time it takes to execute N
> iterations.  Up to this point, I have always gotten a trend that is
> linear, which makes sense.
>         However, the below graph isn't linear, and I am puzzled as to why.
> The graph seems to suggest that the distribution has an exponential
> component to it.  I have tested this on a couple of windows systems
> and this wasn't a fluke.  Granted, the version of IP that I am using
> isn't the latest/greatest, but regardless of versioning, I am trying
> to understand the mechanism.  Thanks for any thoughts, and my
> apologies if this turns out to be a silly post.
>
> Sincerely,
>
> Steve Chadwick
>
>
>
>

--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the users mailing list