How Fast Does Java Compile?

submited by
Style Pass
2024-11-25 08:30:04

Java compiles have the reputation for being slow, but that reputation does not match today’s reality. Nowadays the Java compiler can compile "typical" Java code at over 100,000 lines a second on a single core. That means that even a million line project should take more than 10s to compile in a single-threaded fashion, and should be even faster in the presence of parallelism

Doing some ad-hoc benchmarks, we find that although the compiler is blazing fast, all build tools add significant overhead over compiling Java directly:

Although Mill does the best in these benchmarks among the build tools (Maven, Gradle, and Mill), all build tools fall short of how fast compiling Java should be. This post explores how these numbers were arrived at, and what that means in un-tapped potential for Java build tooling to become truly great.

Mockito is a medium-sized Java project with a few dozen sub-modules and about ~100,000 lines of code. To give us a simple reproducible scenario, let’s consider the root mockito module with sources in src/main/java/, on which all the downstream module and tests depend on.

Leave a Comment