Java vs Python Benchmarks: Java is faster

Bryan bryan at eevolved.com
Thu Jan 31 09:06:52 EST 2002


For what it is worth to people, I have taken the liberty of benchmarking 
the new Java SDK ( 1.4.0 ) against Python 2.1 and 2.2. The tests originate 
from:

http://www.twistedmatrix.com/users/glyph/rant/python-vs-java.html

Point form Summary:

- Java has improved its Standard Output
- Java has improved its Hash table implementation
- Java has improved its IO routines
- Java has improved its Object Allocation

- Python has improved its Native methods
- Python has improved its interpreter speed
- Python allocates objects 57 times slower than java

- Both Python and Java have increased their interpreter initialization 
times, but Python has done so by a much smaller margin.

Interesting differences between Python 2.1 and 2.2:

- I/O is slower in 2.2
- List and Hash are slightly improved in 2.2
- Object allocation shows slight improvement
- Interpreter intialization time has doubled in 2.2

The Results (fixed-font, space-formatted):

JDK 1.4.0 vs Python on an 800Mhz Pentium 3, 512 MB RAM,
Unloaded linux 2.4.8 i686 system, no X-Windows, few daemons.
Internet: 400 KB/s Down, 15 KB/s up. Results are an average of 10 tests.

                Java2     Python 2.1   Summary
                -----     ----------   -------
ConsoleTest     12.34     8.3          Python is 1.4 times faster
HashTest        0.98      2.14         Java is 2.18 times faster
IOTest          2.63      10.25        Java is 3.8 times faster
ListTest        0.65      2.95         Java is 4.5 times faster
NativeTest      1.40      2.29         Java is 1.6 times faster
NoTest          0.34      0.02         Python is 17 times faster
ObjectTest      1.10      62.79        Java is 57 times faster
SpeedTest       0.34      0.64         Java is 1.8 times faster
URLTest         14.53     13.69        Python and Java are equivalent*


                Java2     Python 2.2   Summary
                -----     ----------   -------
ConsoleTest     12.34     8.72         Python is 1.4 times faster
HashTest        0.98      2.1          Java is 2.14 times faster
IOTest          2.63      11.63        Java is 4.4 times faster
ListTest        0.65      2.71         Java is 4.16 times faster
NativeTest      1.40      2.26         Java is 1.6 times faster
NoTest          0.34      0.04         Python is 8.5 times faster
ObjectTest      1.10      61.71        Java is 56.1 times faster
SpeedTest       0.34      0.63         Java is 1.8 times faster
URLTest         14.53     14.71        Python and Java are equivalent*


* The slight discrepancies are most likely due to network fluctuations.


As a side note, I am very much a python proponent. Speed is not everything,
otherwise we would still be coding in straight machine language :) If this 
serves to debunk one pythoneer's baseless comments on the slow speed of 
Java ( as it did to me ) then it has served its purpose.

Happy coding,
-- 
Bryan Mongeau
http://www.eevolved.com/bryan
--
"Imagination is more important than knowledge."-- Einstein




More information about the Python-list mailing list