title: How to calculate execution time (php directive 'max_execution_time'? )
body: <p>A few days ago wrote a php script that goes through all my music and reads id3 tags for each song and inserts those in a mysql database.  Here's a snippet for context:</p>
  
  <pre><code>exec ( "find /songs -type f -iname '*mp3'", $song_path );
  $number_of_songs = count($song_path);
  for($i=0; $i&lt;$number_of_songs; $i++){
      //read id3 tags
      //store id3 tags into database
  }
  </code></pre>
  
  <p>I changed the php directive <code>max_execution_time</code> in apache2/php.ini to gain a better understanding of what this directive does.</p>
  
  <p>When I set <code>max_execution_time = 10</code>, my php script runs for about 45 seconds and successfully reads the id3 tags for about 150 songs (Out of thousands of songs) and inserts those tags into a mysql database before terminating the script and outputting the following to the screen:</p>
  
  <p><strong>Fatal error: Maximum execution time of 10 seconds exceeded in /websites/.../public_html/GetID3()/getid3/module.audio.mp3.php on line 1894</strong> </p>
  
  <p>From the documentation, <em>'The maximum execution time is not affected by system calls, stream operations etc'</em>  <a href="http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time" rel="nofollow">http://www.php.net/manual/en/info.configuration.php#ini.max-execution-time</a></p>
  
  <ol>
  <li><p>What can I infer from the difference between the
  <code>maximum_execution_time</code> being set at 10 seconds and the script
  running for a total of 45 seconds before terminating?  Does this
  mean out of the 45 seconds, 35 were spent doing non-php related
  activities like reading the id3 tags, inserting data into mysql etc..., while 10 were spent
  doing php related activities like iterating the loop?</p></li>
  <li><p>Is there a way I can calculate the execution time and print it to
      the screen?</p></li>
  </ol>
  
  <p><strong>EDIT</strong>
  Using the timer Dagon suggested, I called the getTime() function at the end of the loop, there were about 100+ iterations of the loop.  Here is the output to my browser:</p>
  
  <p>0.1163 seconds</p>
  
  <p>0.8142 seconds</p>
  
  <p>1.1379 seconds</p>
  
  <p>1.5555 seconds</p>
  
  <p>...</p>
  
  <p>76.7847 seconds</p>
  
  <p>77.2008 seconds</p>
  
  <p>77.6071 seconds</p>
  
  <p>Fatal error: Maximum execution time of 10 seconds exceeded in /websites/.../public_html/GetID3()/getid3/module.audio.mp3.php on line 505 </p>