title: Huge performance lack in emscripten code
body: <p>it's 2:50 AM here and after a hectic day I found something strange. I do my best to give a picture of my problem. </p>
  
  <p>I wrote these two pieces of code in <code>C++</code> and <code>JavaScript</code>:</p>
  
  <pre><code>#include&lt;stdio.h&gt;
  #include &lt;time.h&gt;
  
  int main() {
      clock_t tStart = clock();
  
      int result = 0;
      for (int a = 0; a &lt; 1000000000;a++) {
          result += a;
      }
  
      printf("Time taken: %.2fs\n", (double)(clock() - tStart)/CLOCKS_PER_SEC);
  
    return 1;
  }
  </code></pre>
  
  <p>And:</p>
  
  <pre><code>var start = new Date().getTime();
  
  var result = 0;
  
  for(var a = 0;a &lt; 1000000000;a++) {
      result += a;
  }
  
  var end = new Date().getTime();
  var time = end - start;
  console.log('Time taken: ' + (time/1000) + 's');
  </code></pre>
  
  <p>Both of them do the same thing (I hope so)</p>
  
  <p>After generating <code>./a.out.js</code> using the latest version of emscripten, I found something weird:
  <img src="https://i.stack.imgur.com/0mHDK.png" alt="the result of executing both codes"></p>
  
  <p>The execution time of the emscripten code is really slower than the manually written JavaScript code. What's the problem?</p>