Tuesday, 24 July 2012

Compilation Speed of ecj vs javac

For the longest time, I've taken it as an article of faith that the eclipse compiler (ecj) was significantly faster than the default Sun java compiler (javac). The last time I measured this properly was when I compared the Java5 compiler against the equivalent ecj release. After a recent conversation, I realised that I was still making the same assertion, despite over two years having elapsed.

So, time to measure again. And this time, the results surprised me. What used to be a whitewash for ecj has now changed to a slight edge being given for javac.

The test was done by repeating a build of the java components of the selenium codebase 20 times on an OS X machine running Lion and the latest released version of Java 7 from Oracle. The machine itself has 12GB of RAM and the development wasn't being done on an SSD. The results were:

javac: avg. 29.9s with a standard deviation of 0.80s
ecj: avg. 31.1s with a standard deviation of 0.82s