|
|
About
Christian Simms's Software R&D, Generative Programming and other R&D.
Subscribe
Subscribe to a syndicated feed of my weblog,
brought to you by the wonders of RSS.
Links
These are a few of my favorite links.
Oligopoly Watch
Google News
The Register
Slashdot
F***edCompany
Drudge Report
The Economist
|
|
|
Sat, 31 May 2003
In my spare time, I've been developing a J2EE code generator using python.
However, I noticed that as I added new features, the performance was degrading
considerably, so I decided to do some benchmarks. This is what I found.
Below, each column name is a link to the source code for the given language.
Each program is written in the style for that language, so for instance the Python
version uses the built-in dictionary for hash tables, whereas the Java version uses
HashMap class. Notice how these tests don't do something simple like test
using hashes of int's, because I haven't had to do that kind of thing since college.
| Test |
Python |
Java (classic) |
Java (hotspot) |
C# |
g++ |
g++ (-O3) |
| Dynamic Object Allocation |
141,000/sec |
168,000/sec |
1,400,000/sec |
52,300,000/sec |
1,060,000/sec |
1,450,000/sec |
| Dynamic Object Allocation plus hash table get/set |
9,880/sec |
4,670/sec |
56,300/sec |
53,800/sec |
19,100/sec |
30,200/sec |
So what can we learn from this?
- Java with hotspot compares favorably to C#
- Java with hotspot is something like 10x faster than without
- Python's about 5x slower than Java/C#
- And most surprising (to me): Java and C# were both about twice as fast as C++! I had read that could be true, but seeing is believing.
I tried speeding up the Python code using the Psycho JIT compiler,
but without much luck. Actually, it was slightly slower (maybe 10% slower), and I think I know why. The Python versions
of these tests primarily test the memory allocator and built-in dictionary type, neither of which can be JIT'ed because
they're already native in the Python language, so I just saw the overhead of the JIT).
[]
permanent link
|
|