Community Documentation

How to measure the execution time of your Drupal scripts

Last updated October 14, 2010. Created by Davy Van Den Bremt on October 12, 2008.
Edited by corbacho, wmostrey. Log in to edit this page.

While doing Drupal development, you sometimes might want to find out how fast or slow a certain part in your code is. Did you know that Drupal has 3 easy functions to do this built right in to core, timer_start($name), timer_read($name) and timer_stop($name).

You can have multiple timers in one run and each one of them is identified by the $name parameter you have to pass to each of these three functions.
I think the functions are pretty self explanatory:

  • timer_start starts a timer
  • timer_read tells you how long the timer has been running
  • and timer_stop stops the timer and returns an array that contains the number of times the timer has been started and stopped (count) and the accumulated timer value in ms (time).

Source: http://www.drupalcoder.com/story/336-how-to-measure-the-execution-time-o... (Drupal 5.x)

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 6.x
Audience
Developers and coders

Develop for Drupal

Drupal’s online documentation is © 2000-2012 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License.
nobody click here