Message5584

Author zyasoft
Recipients pr3d4t0r, zyasoft
Date 2010-03-21.22:08:30
SpamBayes Score 9.141854e-08
Marked as misclassified No
Message-id <1269209311.54.0.0173535090142.issue1571@psf.upfronthosting.co.za>
In-reply-to
Content
Some test results for 2.5.1 of Jython show that we have to let hotspot heat up first, in which case it eventually outperforms CPython 2.6.4:

jimbaker:~ jbaker$ released-jython2.5.1/bin/jython -m timeit -n 1000 "int('12345')"
1000 loops, best of 3: 12 usec per loop
jimbaker:~ jbaker$ released-jython2.5.1/bin/jython -m timeit -n 10000 "int('12345')"
10000 loops, best of 3: 3.3 usec per loop
jimbaker:~ jbaker$ released-jython2.5.1/bin/jython -m timeit -n 100000 "int('12345')"
100000 loops, best of 3: 0.53 usec per loop
jimbaker:~ jbaker$ released-jython2.5.1/bin/jython -m timeit -n 1000000 "int('12345')"
1000000 loops, best of 3: 0.416 usec per loop
jimbaker:~ jbaker$ released-jython2.5.1/bin/jython -m timeit -n 10000000 "int('12345')"
10000000 loops, best of 3: 0.402 usec per loop

vs CPython 2.6.4:

jimbaker:~ jbaker$ python -m timeit -n 10000 "int('12345')"
10000 loops, best of 3: 0.731 usec per loop

I doubt there's any caching behavior here on the string itself. A naive variant I wrote is not nearly as fast for large number of iterations, almost certainly because it doesn't inline as well:

jimbaker:jython jbaker$ dist/bin/jython -m timeit -n 10000 "int('12345')"
10000 loops, best of 3: 8.7 usec per loop
jimbaker:jython jbaker$ dist/bin/jython -m timeit -n 100000 "int('12345')"
100000 loops, best of 3: 8.69 usec per loop

I believe this is because it doesn't aggressively inline. We can do better by removing all conditional logic within the inside loop, such as around base calcs, but that requires more work for this specialization.
History
Date User Action Args
2010-03-21 22:08:31zyasoftsetmessageid: <1269209311.54.0.0173535090142.issue1571@psf.upfronthosting.co.za>
2010-03-21 22:08:31zyasoftsetrecipients: + zyasoft, pr3d4t0r
2010-03-21 22:08:31zyasoftlinkissue1571 messages
2010-03-21 22:08:30zyasoftcreate