[IronPython] Sin and Sqrt performance (Chris Trimble)

Chris Trimble trimble at pobox.com
Mon Apr 17 23:59:06 CEST 2006


I shouldn't have said "no difference".  Should have written... xrange
or while does actually make around a 10% difference.  Of course this
is nowhere near the 500x performance increase that C# seems to offer,
which is why I said "no difference". :)

Thanks,

 - C


On 4/17/06, Chris Trimble <trimble at pobox.com> wrote:
> Did you try making the change on your end and see a change?  It makes
> no difference on my end.
>
> BTW, I had tried 'while' before making the original post.  No
> difference there either.  In fact, range() has better performance than
> 'while' in CPython for this code!
>
>   - Chris
>
>
>
>
> On 4/17/06, Dave <midnightdf at yahoo.com> wrote:
> > Use xrange instead of range and there should be a pretty good performance
> > improvement;) As is, your for loop creates a list of five million elements.
> > A simple while loop would also do the trick although it's not as clean to
> > look at.
> >
> > Dave
> >
> > users-request at lists.ironpython.com wrote:
> >  Send users mailing list submissions to
> >  users at lists.ironpython.com
> >
> > To subscribe or unsubscribe via the World Wide Web, visit
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> > or, via email, send a message with subject or body 'help' to
> >  users-request at lists.ironpython.com
> >
> > You can reach the person managing the list at
> >  users-owner at lists.ironpython.com
> >
> > When replying, please edit your Subject line so it is more specific
> > than "Re: Contents of users digest..."
> >
> >
> > Today's Topics:
> >
> >  1. Sin and Sqrt performance (Chris Trimble)
> >
> >
> > ----------------------------------------------------------------------
> >
> > Message: 1
> > Date: Mon, 17 Apr 2006 11:47:35 -0700
> > From: "Chris Trimble"
> > Subject: [IronPython] Sin and Sqrt performance
> > To: "Discussion of IronPython"
> > Message-ID:
> >
> > Content-Type: text/plain; charset=ISO-8859-1
> >
> > IP doesn't do much better than CPython when using math.sin and
> > math.sqrt. However, same test in C# dominates (10ms.. as opposed to
> > upwards of 5 seconds in IP or CPy). Am I missing something here?
> >
> > Thanks,
> >
> >  - Chris
> >
> > -----------------------------------
> >
> > import time
> > from math import *
> >
> > def do_timing(f, reps):
> >  start = time.time()
> >  f(reps)
> >  end = time.time()
> >  print "%s (%d reps): %f" % (f.__name__, reps, end-start)
> >
> >
> > def py_fpfunc_test(reps):
> >  j = 0.0
> >  for i in range(0, reps):
> >  j += sin( j )
> >  j += sqrt( j )
> >  j +=2.72392032032;
> >  print j
> >
> > def do_all_timing():
> >  do_timing(py_fpfunc_test, 5000000)
> >
> > do_all_timing()
> > print ""
> >
> >
> > ------------------------------
> >
> > _______________________________________________
> > users mailing list
> > users at lists.ironpython.com
> > http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> >
> >
> > End of users Digest, Vol 21, Issue 18
> > *************************************
> >
> >
> >
> >  ________________________________
> > How low will we go? Check out Yahoo! Messenger's low PC-to-Phone call rates.
> >
> >
> > _______________________________________________
> > 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