<?php

// MYSQL INFO
$hostname = "localhost";
$username = "root";
$password = "";

// get start time
$START_TIME = microtime();

// enable error checking
if (!defined('E_STRICT')) { define('E_STRICT', 2048); } // define E_STRICT for PHP < 5
error_reporting(E_ALL | E_STRICT);  // display all errors
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');

// timer function
function showExecuteSeconds() {
  $endTime   = microtime();

  list($start_msec, $start_sec) = explode(" ", $GLOBALS['START_TIME']);  // START_TIME is set in init.php
  list($end_msec, $end_sec)     = explode(" ", $endTime);

  $diff_sec  = intval($end_sec) - intval($start_sec);
  $diff_msec = floatval($end_msec) - floatval($start_msec);
  $totalTime = floatval( $diff_sec ) + $diff_msec;
  $value     = sprintf("%0.2f", $totalTime);

  print "Total Time: $value seconds<br/><br/>\n";
}


//
print "<h1>Testing MySQL Speed</h1>";
showExecuteSeconds();

// connect to mysql
print "Connecting to MySQL...<br/>";
mysql_connect($hostname, $username, $password) or die("Error connecting to MySQL: " . mysql_error());
showExecuteSeconds();

//
print "Done";

?>
