title: Matlab tic toc accuracy
body: <p>I'm measuring some code in loop</p>
  
  <pre><code>fps = zeros(1, 100);
  for i=1:100
  
      t = tic
      I = fetch_image_from_source(); % function to get image
      fps(i) = 1./ toc(t);
  
  end
  plot(fps);
  </code></pre>
  
  <p>And I get average 50 fps.</p>
  
  <p>Then I'd like to add <code>imshow()</code> to my code. I understand that <code>imshow</code> is very slow, but I won't include <code>imshow</code> inside <code>tic-toc</code> commands:</p>
  
  <pre><code>fps = zeros(1, 100);
  figure;
  for i=1:100
  
      t = tic
      I = fetch_image_from_source(); % function to get image
      fps(i) = 1./ toc(t);
  
      imshow(I); drawnow;
  
  end
  plot(fps);
  </code></pre>
  
  <p>And I get fps about 20%-30% slower. Why does it happen? Because <code>imshow()</code> is outside <code>tic-toc</code></p>