title: Why running executable in command line faster?
body: <p>I coded a short program in C++ that is basically a method for filling an array of double with some math calculation through for loop, for the purpose of performance measurements and comparisons. I noticed that if I run the exe file through the command line (just type the file name and enter) I get significantly better results from <code>std::chrono</code> (wrapping the method within main method) than if I run it by double click the file. Does anyone have any idea why this performance difference might be due?</p>
  
  <p>EDIT -- this is the function:</p>
  
  <pre><code>    double* MakeCalc()
      {
          double* retval = new double[5000 * 5000];
          int ind = 0;
          for (int i = 0; i &lt; 5000; i++)
          {
              for (int j = 0; j &lt; 5000; j++)
              {
                  retval[ind++] = i * j;
              }
          }
          delete[] retval;
          return retval;
      }
  
  main function
  
      int main()
      {
          auto start = chrono::high_resolution_clock::now();
          MakeCalc();
  
          auto end = chrono::high_resolution_clock::now();
          auto duration = chrono::duration&lt;float&gt;(end - start);
  
          std::cout &lt;&lt; "execution time: " &lt;&lt; duration.count() &lt;&lt;" sec" &lt;&lt; '\n';
  
          system("pause");
          return 0;
      }
  
  </code></pre>