You are not logged in.
Hi all,
I recently posted a speed comparison of Python vs Java.
Following Xentac's suggestion, I imported Psyco to see if I could get any JIT benefits in the Python scripts. I then tried the latested Java JDK6 dev binaries too. This follow-up can be found here.
Please be aware that I'm totally aware of the vast limitations of micro-benchmarks like these. Still, although they are based on someone else's code, I like them because they represent the typical tasks I often carry out in both my Python and Java programming: IO, lists, hashes, for loops, etc.
Any comments welcome, especially on how to optimise the Python code. I can already see a couple of ways that ought to improve the Java tests.
Offline
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
Ah, I forgot about this site - 'tis well cool.
So, this also confirms that Java is lighter on the CPU. However, this also highlights the obvious that Java takes up more memory (I'd say an average of 5% more).
Did anyone notice how the table of results is a bit odd. They talk about values < 1, but there no negative numbers. My assumption is that the values with the shading behind represent -ve numbers.
Offline
Relative performance: values > 1 mean the Java program used more than the Python program; values < 1 mean the Java program used less than the Python program.
yeah. it seems the range from 0 to 1 is somehow caculated differently than from 1 to infinity. I don't get it either i guess.
I find the bar graph useful, and the win/loss table at the bottom very interesting.
my poor ruby is a bit slow it seems. Oh well, I guess there is a small price to pay for elegance in the language. Hopefully it will get better in coming versions.
"Be conservative in what you send; be liberal in what you accept." -- Postel's Law
"tacos" -- Cactus' Law
"t̥͍͎̪̪͗a̴̻̩͈͚ͨc̠o̩̙͈ͫͅs͙͎̙͊ ͔͇̫̜t͎̳̀a̜̞̗ͩc̗͍͚o̲̯̿s̖̣̤̙͌ ̖̜̈ț̰̫͓ạ̪͖̳c̲͎͕̰̯̃̈o͉ͅs̪ͪ ̜̻̖̜͕" -- -̖͚̫̙̓-̺̠͇ͤ̃ ̜̪̜ͯZ͔̗̭̞ͪA̝͈̙͖̩L͉̠̺͓G̙̞̦͖O̳̗͍
Offline
i've tried both psyco and pyrex,
about psyco i didn't notice any speed improvements at all, i think you must fix the code somehow to fit psyco better,
and pyrex compiles python and pyrex code (pyrex code is modified python code with c declared functions and statically declared variables) down to python c code which you compile with gcc, so fully optimized pyrex runs with c speed so that's not a fair comparison to just pure java, in that case you should compare it to native java(gcj?),
and about the benchmarks, well, the differences are probably so small that it doesn't matter in most cases, i'm not using java myself but complaints I hear from other people usually are about startup/respons times and memory consumption and not about the actual running of the app so i don't think aroos figures are wrong at all which also that other sites benchmarks showed, weren't java a tad faster there also?
arch + gentoo + initng + python = enlisy
Offline
I agree. I honestly am not trying to say that Java is better and Python is rubbish. I love em both. There's not a great deal of difference for the most part.
I just felt that people assumed that Java was slow because they've heard it's slow, or had prior experience of the old versions.
I have friend's saying "ugh, Java is sloowwww." And so avoid it. Yet, these same people rave about Perl and Python apps. My point was simply, hate Java for other reasons - not speed!
You may notice that the Java executable is only 63K. The bulk of Java comes from its extensive class library that ships with the runtime. People think that Java must load up all the classes or something before running, when in fact it only ever loads with it needs. So, whilst the package itself is large, any sure, it does require more memory than other languages, I just don't believe it's as bulky as some assume.
The motivation for those benchmarks was a comment on Frugalware's IRC channel where someone tried it out, said it was slow, removed it, and preferred the Python/gtk front-end they have instead. Followed with some insightful remark that Java only for web apps! I don't mind others prefering other front-ends. But is Jacman really slow? Please tell me, because it runs like a dream on my system. It would go even quicker if with pacman-optimize.
Offline
i've tried both psyco and pyrex,
about psyco i didn't notice any speed improvements at all, i think you must fix the code somehow to fit psyco better,
I have written a simple game and hat +40 frames when using psyco, so I guess there is a speed difference.
Offline
do you mean 40 frames more with psyco?
well, maybe you've found out how it really works,
I have friend's saying "ugh, Java is sloowwww." And so avoid it. Yet, these same people rave about Perl and Python apps. My point was simply, hate Java for other reasons - not speed!
are there any big pure python/pygtk apps out there really?
someone should write an exact clone of azureus in python/pygtk and compare them side by side irl use,
arch + gentoo + initng + python = enlisy
Offline
yes, 40 frames more with psyco, I used it like this:
if options.jit_compile:
try:
import psyco
psyco.log()
if options.jit_method == 'profile':
psyco.profile()
elif options.jit_method == 'full':
psyco.full()
except ImportError, err:
print "::warning no psyco jit-compilation available. %s" % err
Offline
My point was simply, hate Java for other reasons - not speed!
Syntax!!
Offline
arooaroo wrote:My point was simply, hate Java for other reasons - not speed!
Syntax!!
I see your point, but I laughed out loud when i saw that response...and now everyone is looking at me weird (at work of course)...I was sort of thinking the same thing.
Offline
arooaroo wrote:My point was simply, hate Java for other reasons - not speed!
Syntax!!
lol. Indeed - it's getting uglier, that's for sure.
Of course, if I was using a Java app, then syntax wouldn't be an issue.
Offline
what exactly is wrong with the Java syntax ?
Offline
I love Java syntax... only I hate it too...
Offline
I love Java syntax... only I hate it too...
I think i've thought this about every language I've used (well, except maybe perl .
Hobbes : Shouldn't we read the instructions?
Calvin : Do I look like a sissy?
Offline
I love Java syntax... only I hate it too...
So are you officially a java hater now?
I mean, do you ever use java anymore?
Offline
So are you officially a java hater now?
I mean, do you ever use java anymore?
I take it you didn't see Dusty's Sick of Java thread then?!
Offline
Euphoric Nightmare wrote:So are you officially a java hater now?
I mean, do you ever use java anymore?
I take it you didn't see Dusty's Sick of Java thread then?!
No...I saw it. I didn't know if he was going to stop using it 100% or not. I had heard that he was redoing ensmer in python as well...I'm just curious mainly i guess.
Offline
So are you officially a java hater now?
No. I don't really hate any languages, except SQL and Basic, but they're so bad, I don't really think they even qualify as languages.
I mean, do you ever use java anymore?
Since I wrote the sick of Java thread, I have done approximately no programming whatsoever, so its hard to answer that.
Dusty
Offline
interesting...
yeah...SQL and basic do suck...good point
Offline
I think it makes sense that Java is faster, as you have to declare your variables, for example, while Python has to figure it out itself.
Different languages for different goals, I guess.
Some PKGBUILDs: http://members.lycos.co.uk/sweiss3
Offline
Something interesting... http://www.flat222.org/mac/bench/
Offline
Just confirms what I said with regards to Java vs Python.
Of course, if you were to benchmark the time it takes to write an algorithm for task X in Java and Python, it would probably be the other way around!
Offline