JVM Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 4.10

"long" Loops with JIT Compilation

This section provides a tutorial example on benchmark testing of 'long' operations in loops with JIT compilation.

Now let's repeat those "long" test methods with JIT compilation and these parameters:

  • "warmups=10000" benchmark runner parameter to ensure the JIT compiler finishes all compilations.
  • "runs=100" benchmark runner parameter to repeat the test 100 times to average out interruptions from the operating system.
  • "steps=1000000" benchmark runner parameters to minimize the loop overhead.

Here are test results:

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong emptyLoop 10000 100 1000000
...
Runs: 100, Ave: 2, Min: 2, Max: 2 - Per step in nanoseconds

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong assignment 10000 100 1000000
...
Runs: 100, Ave: 3, Min: 3, Max: 3 - Per step in nanoseconds

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong shift 10000 100 1000000
...
Runs: 100, Ave: 4, Min: 4, Max: 4 - Per step in nanoseconds

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong add 10000 100 1000000
...
Runs: 100, Ave: 3, Min: 3, Max: 3 - Per step in nanoseconds

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong multiply 10000 100 1000000
...
Runs: 100, Ave: 5, Min: 5, Max: 5 - Per step in nanoseconds

C:\herong\jvm>java -Xms100m -Xmx100m
   BenchmarkRunner BenchmarkTestLong division 10000 100 1000000
...
Runs: 100, Ave: 24, Min: 24, Max: 25 - Per step in nanoseconds

No surprises here:

  • The division operation is much more expensive that other operations.
  • Execution in JIT compilation mode is much faster than interpreted-only mode.
  • "long" operations are 3 to 4 times slower that "int" operations in JIT compilation mode.

Last update: 2010.

Table of Contents

 About This Book

 Download and Install Java SE 1.6 Update 2

 java.lang.Runtime Class - The JVM Instance

 java.lang.System Class - The Operating System

 ClassLoader Class - Class Loaders

 Class Class - Class Reflections

 Sun's JVM - Java HotSpot VM

 JRockit JVM 7.0 by BEA Systems

 JRockit JVM 8.0 by BEA Systems

 Memory Management Rules and Tests

 Garbage Collection Tests

 Stack Overflow Tests

 Thread Testing Program and Result

 StringBuffer Testing Program and Result

 CDS (Class Data Sharing)

 Micro Benchmark Runner and JVM Options

 Micro Benchmark Tests on "int" Operations

 Micro Benchmark Tests on "long" Operations

Micro Benchmark Tests in JIT Compilation Mode

 "int" Loops with JIT Compilation

"long" Loops with JIT Compilation

 Performance Improvements of JIT Compilation

 Micro Benchmark Tests on "float" and "double" Operations

 References

 PDF Printing Version

Dr. Herong Yang, updated in 2010
"long" Loops with JIT Compilation