title: Oracle vs IBM Java performance
body: <p>I'm trying to compare the performance of the two main Java implementations: Oracle and IBM on running the following test:</p>
  
  <pre><code>public class HarmonicSeriesTest {
  
      public static void main(String[] args) {
          long startTime = System.currentTimeMillis();
          final int limit = 20;
          double sum = 0.0;
          long n = 0;
          while (sum &lt; limit) {
              n++;
              sum += 1.0 / n;
          }
          long duration = System.currentTimeMillis() - startTime;
          System.out.printf("n is %d\n", n);
          System.out.printf("Executed in %d miliseconds\n", duration);
      }
  }
  </code></pre>
  
  <p>By running the above code with: </p>
  
  <ol>
  <li>IBM JRE 1.8.0 </li>
  </ol>
  
  <blockquote>
    <p>java version "1.8.0" Java(TM) SE Runtime Environment (build
    pwa6480sr3fp22-20161213_02(SR3 FP22)) IBM J9 VM (build 2.8, JRE 1.8.0
    Windows 10 amd64-64 Compressed References 20161209_329148 (JIT
    enabled, AOT enabled) J9VM - R28_20161209_1345_B329148 JIT  -
    tr.r14.java.green_20161207_128946 GC   -
    R28_20161209_1345_B329148_CMPRSS J9CL - 20161209_329148) JCL -
    20161213_01 based on Oracle jdk8u111-b14</p>
  </blockquote>
  
  <ol start="2">
  <li>Oracle JRE 1.8.0_131</li>
  </ol>
  
  <blockquote>
    <p>java version "1.8.0_131" Java(TM) SE Runtime Environment (build
    1.8.0_131-b11) Java HotSpot(TM) 64-Bit Server VM (build 25.131-b11, mixed mode)</p>
  </blockquote>
  
  <ol start="3">
  <li>Sun JRE 1.5.0_22</li>
  </ol>
  
  <blockquote>
    <p>java version "1.5.0_22" Java(TM) 2 Runtime Environment, Standard
    Edition (build 1.5.0_22-b03) Java HotSpot(TM) 64-Bit Server VM (build
    1.5.0_22-b03, mixed mode)</p>
  </blockquote>
  
  <p>I consistently get the following results:</p>
  
  <ol>
  <li>IBM JRE 1.8.0 Compiler compliance level 1.8</li>
  </ol>
  
  <blockquote>
  <pre><code>n is 272400600
  Executed in 1024 miliseconds
  </code></pre>
  </blockquote>
  
  <ol start="2">
  <li>Oracle JRE 1.8.0_131 Compiler compliance level 1.8</li>
  </ol>
  
  <blockquote>
  <pre><code>n is 272400600
  Executed in 2002 miliseconds
  </code></pre>
  </blockquote>
  
  <ol start="3">
  <li>Sun JRE 1.5.0_22 Compiler compliance level 1.5</li>
  </ol>
  
  <blockquote>
  <pre><code>n is 272400600
  Executed in 1506 miliseconds
  </code></pre>
  </blockquote>
  
  <p>As you can see, the Oracle JRE is slower by 100% compared to IBM JRE and 25% compared to Sun JRE. The gap between Oracle and IBM implementations is huge, also Oracle JRE looks like a regression over Sun JRE.</p>
  
  <p>Does anyone have an explanation why is the 'official' implementation of Java so slow?</p>
  
  <p><strong>I have no interest in using JMH since I don't want to benchmark anything.</strong></p>
  
  <p>Bellow is the hardware configuration I used for testing:</p>
  
  <p><a href="https://i.stack.imgur.com/99CwI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/99CwI.png" alt="This is the hardware configuration"></a></p>