Archive for September, 2011

September 4th 2011

Addition is free, static compilation is expensive

Summing the integers from 1 to 10,000,000?

  • Perl: 1.01 seconds
  • Python: 2.04 seconds
  • Java, including javac: 0.76 seconds
  • Java, including ecj: 0.61 seconds
  • Java, including javac, with -Xint: 1.01 seconds.
  • Java, including javac, with -Xint on the compiler too: 1.16 seconds.
  • -Xint disables practically all optimisations that Java offers, forcing the JVM into interpretation mode, so it’ll operate much like perl and python do.
  • ecj is Eclipse’s compiler for Java, a faster and cleaner implementation of javac that can run standalone.

i.e. including compilation time on an entirely unoptimised compiler, Java is still twice the speed of Python.

(This isn’t really interesting or surprising to me, but the question comes up often enough that I’d like to have these here to link WRONG people to.)

Continue Reading »

No Comments yet »