Strange performance behavior in JavaScript
<p>I was trying to evaluate some JavaScript runtime behavior, and got stuck on a phenomenon. It's in this fiddle: <a href="https://jsfiddle.net/Rolf_b/d23wq3hu/" rel="nofollow">https://jsfiddle.net/Rolf_b/d23wq3hu/</a></p>

<p>It contains some simple HTML</p>

<pre><code>&lt;label for="loopCount"&gt;Test loops: &lt;/label&gt;
&lt;input id="loopCount" type="text" value="10000000" /&gt;
&lt;input id="testbutton" type="button" value="Run Test" /&gt;
&lt;p id="result"&gt;Choose Loop Count and click Run Test&lt;/p&gt;
</code></pre>

<p>and a bit of JavaScript for my test. I define a constructor function that creates some getter/setter properties, because that's what I wanted to benchmark. For measuring, I hook a function on the click-event of my test button, show "Running", give the browser the chance to display that and continue with a simple time-measured loop.</p>

<pre><code>var MyClass = function() {
    var aValue = 3;
    //var sym = Symbol();    // Uncomment this to get BETTER TIMING. WTF?
    //this[sym] = 123;
    Object.defineProperties(this, {
       myVal: { get: function() { return aValue; },
                set: function(v) { aValue = v; } },
       aCalc: { get: function() { return 2+3*aValue; } } } ); 
    };     

document.getElementById('testbutton').addEventListener('click', function() {
  document.getElementById('result').innerText = "Running...";
  setTimeout(function() {
    var loopCount = parseInt(document.getElementById('loopCount').value);
    var startTime = new Date(),
          endTime,
          i, j = 0,
          c = new MyClass();

      for (i = 0; i &lt; loopCount; i++) {
        j++;
        if (c.aCalc != 11) alert('Wrong at ' + j);
      }
      endTime = new Date();   
    document.getElementById('result').innerText = 'Done, time was ' + (endTime-startTime) + ' ms, j='+  j;
  }, 0);
});
</code></pre>

<p>The problem: inconsistent timing behaviour. With Chrome 50, the first click needs about 70ms, and MOST of the following clicks a whopping 1100ms. Not all, a few complete in 70ms, too. With Chrome for Android, the same (only slower). With the ASUS Browser on my tablet: about 500ms for the first click, then slowly increasing to 600ms-700ms. And then, Internet Explorer 11 (because I am a Win7 boy): 330ms for first click and about 250ms for every next click.</p>

<p>I can understand if the first click is slower. JIT compile, some things are cached. But Chrome? Factor 20 to 100? Just because I use a getter function? And why is the first call fast, and the rest is slow?</p>

<p>Edit May 09: If you uncomment the two lines in the MyClass constructor, the timing becomes BETTER. The first call is still fast, and subsequent calls are slower, but they are about 9 times faster than without the symbol. And it has to be a Symbol, a string doesn't help.</p>

<p>Can anybody enlighten me what's happening here?</p>