title: Why is my code running faster if i compiled it with codeBlocks
body: <p>i wanted to measure the fps of my camera. I found a simple code <a href="https://www.learnopencv.com/how-to-find-frame-rate-or-frames-per-second-fps-in-opencv-python-cpp/" rel="nofollow noreferrer">here</a>.
  If i compile the code with codeBlocks (on Ununtu) and run the loop for 600 times, the result is 27 fps.</p>
  
  <p>if i compile it from the terminal with: </p>
  
  <pre><code>    g++ -Wall main.cpp -o  main -I/usr/local/include/ -lopencv_core -lopencv_highgui
  </code></pre>
  
  <p>the result is 14 fps. Why is it so slow after compiling from the terminal?</p>
  
  <p>Here is the code</p>
  
  <pre><code>#include "opencv2/opencv.hpp"
  #include &lt;time.h&gt;
  
  using namespace cv;
  using namespace std;
  
  int main(int argc, char** argv)
  {
  
  // Start default camera
  VideoCapture video(0);
  
  // With webcam get(CV_CAP_PROP_FPS) does not work.
  // Let's see for ourselves.
  
  double fps;
  
  
  // Number of frames to capture
  int num_frames = 600;
  
  // Start and end times
  time_t start, end;
  
  // Variable for storing video frames
  Mat frame;
  
  cout &lt;&lt; "Capturing " &lt;&lt; num_frames &lt;&lt; " frames" &lt;&lt; endl ;
  
  // Start time
  time(&amp;start);
  
  // Grab a few frames
  for(int i = 0; i &lt; num_frames; i++)
  {
      video &gt;&gt; frame;
  }
  
  // End Time
  time(&amp;end);
  
  // Time elapsed
  double seconds = difftime (end, start);
  cout &lt;&lt; "Time taken : " &lt;&lt; seconds &lt;&lt; " seconds" &lt;&lt; endl;
  
  // Calculate frames per second
  fps  = num_frames / seconds;
  cout &lt;&lt; "Estimated frames per second : " &lt;&lt; fps &lt;&lt; endl;
  
  // Release video
  video.release();
  return 0;
  }
  </code></pre>