Location: PHPKode > scripts > Simple timer script > example.php

include 'timer.class.php';
$db_timer = new timer();
// Connect to database here and create the query to be run
mysql_connect('localhost', 'root', '');
$query = "SELECT * FROM table";
// Start timer before executing query
$result = mysql_query($query);
// Pause timer
// Echo out the selected data
while($row = mysql_fetch_assoc($result)) {
    echo print_r($row, true);
// Create another query
$query = "SELECT * FROM table2";
// Unpause the timer
// Execute the query
$result = mysql_query($query);
// Stop the timer and get the total execution time
$total_time = $db_timer->stop();
// Display details
echo 'SQL queries took '.$total_time.' seconds to execute in total';
Return current item: Simple timer script