title: JDK 11 vs JDK 13 performance
body: <p><strong>UPDATE</strong></p>
  
  <p>Throughout comments it turned out that the approach for benchmark I taken was incorrect, therefore results were misleading. After correcting my approach (as in accepted answer) results are as one would expect - JDK 13 performance is just as good as with JDK 11. See the answer for more details.</p>
  
  <p><strong>Original question</strong></p>
  
  <p>I was doing some performance benchmarks on HashSet under Windows 10, using following test code for JMH:</p>
  
  <pre><code>@Benchmark
  @BenchmarkMode(Mode.AverageTime)
  @Fork(value = 1, warmups = 1)
  public void init() {
      HashSet&lt;String&gt; s = new HashSet&lt;&gt;();
      for (int i = 0; i &lt; 1000000; i++) {
          s.add(Math.random() + "");
      }
      s.size();
  }
  </code></pre>
  
  <p>I compiled and run it under different JDK versions and here is what results I got:</p>
  
  <p><a href="https://i.stack.imgur.com/vRs2f.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vRs2f.png" alt="enter image description here"></a></p>
  
  <p>I tested it with different heap sizes too (thus 3 different colors for each JDK).
  JDK 14 is of course a pre-release snapshot from today - just to see ZGC performing under Windows.</p>
  
  <p>I wonder - what happened after JDK 11? (note, for JDK 12 it already starts growing, even though it's not present on the chart above)</p>