Will programs get faster just by increasing the Java version?

(This article is a multipost with Go to the Horizon)

I often hear that increasing the running version of Java makes it faster. But is that really the case? And how fast would it be if it were true?

So, I experimented with a simple program.

Experiment outline

For the experiment, I created Java program to solve Sudoku. Since this program only repeats simple operations, the tendency is probably different from that of a complicated program such as a Web application, but I think it will be a reference level.

Compile this with ** Java 1.1 ** and ** with each Oracle JDK (32bit / 64bit) from Java 1.1 to 12 ** Dataset of 1 million questions in Sudoku .com / bryanpark / sudoku / version / 3) was read and the time to complete the solution was measured. [^ compile] **

[^ compile]: Because it is backwards compatible, class files compiled with Java 1.1 will continue to work in later versions.

The detailed measurement conditions are as follows.

[^ jvmoption]: You might wonder, "That's -Xmx -Xms?", But in Java 1.1 this option is -mx`` -ms. In Java 1.2, the VM option was changed to -Xmx`` -Xms, but you can still use -mx`` -ms. [^ server]: Without this option, the HotSpot Client VM would be used, which would be about twice as slow ...

Experimental result

Since the processing is divided into two parts, the graph axis is separated for each processing.

Here are the results of the experiment. 処理時間(ms)

Original data of graph ...
Java Version Data read(ms) Sudoku analysis(ms) total(ms)
Java 1.1 (32bit) 1.1.8 8,313 4,231 12,544
Java 1.2 (32bit) 1.2.2_017 6,647 4,360 11,006
Java 1.3 (32bit) 1.3.0_05 10,747 6,905 17,652
Java 1.3.1 (32bit) 1.3.1_28 7,647 5,093 12,740
Java 1.4 (32bit) 1.4.0_04 8,061 4,741 12,802
Java 1.4.1 (32bit) 1.4.1_07 7,810 4,796 12,606
Java 1.4.2 (32bit) 1.4.2_19 3,437 3,281 6,717
Java 5 (32bit) 1.5.0_22 3,050 3,289 6,338
Java 6 (32bit) 1.6.0_45 3,530 4,077 7,607
Java 7 (32bit) 1.7.0_80 3,411 3,211 6,622
Java 8 (32bit) 1.8.0_202 3,239 3,257 6,496
Java 6 (64bit) 1.6.0_45 5,029 3,312 8,341
Java 7 (64bit) 1.7.0_80 7,019 3,148 10,167
Java 8 (64bit) 1.8.0_202 5,050 3,054 8,104
Java 9 (64bit) 9.0.4 2,101 2,961 5,061
Java 10 (64bit) 10.0.2 2,056 3,054 5,110
Java 11 (64bit) 11.0.3 1,922 3,343 5,265
Java 12 (64bit) 12.0.1 1,934 3,422 5,356

Consideration

The premise is "in this program", but the following can be seen from the data.

[^ cms]: Concurrent Mark Sweep Garbage Collector. For more information on this GC, see KUBOTA Yuji's Material.

Summary

** Just increase the Java version and your program will be faster. ** **

Recommended Posts

Will programs get faster just by increasing the Java version?
Switch the version of java installed by SDKMAN when moving directories
[Java version] The story of serialization
How to get the value after "_" in Windows batch like Java -version
Get the result of POST in Java
[Java] Get the day of the specific day of the week
[Java] How to get the current directory
How to install the legacy version [Java]
How to get the date in java
The story received by Java SE11 silver
[Java] Make programs 10x faster with parallelStream
[Java8] Search the directory and get the file
[Java] Get the date with the LocalDateTime class
I stumbled on the Java version in Android Studio, so I will summarize it