[IronPython] Sin and Sqrt performance (Chris Trimble)
Dave
midnightdf at yahoo.com
Mon Apr 17 23:42:57 CEST 2006
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! Messengers low PC-to-Phone call rates.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20060417/071f8fc7/attachment.html>
More information about the Ironpython-users
mailing list