PHP MySQL response time tester

Modified on Mon, 16 Mar, 2015 at 8:55 PM

Feel free to user our tool here to test MySQL response times: http://www.ispcloud.co.uk/pingMySQL.php?dbserver=IPADDRESS&dbuser=USER&dbpassword=PASS&dbname=NAME
(Replace IPADDRESS with IP address of database server)
(Replace USER with username that has permission to access the database server)
(Replace PASS with the password)
(Replace NAME with the name of the database)


Or, if you'd like to modify the tool feel free to copy our source code below:

 

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<style type="text/css">
.console {
  font-family:Courier;
  font-size: 12pt;
 color: #CCCCCC;
  background: #000000;
  border: 3px double #CCCCCC;
  padding: 10px;
}
</style>
<?php
// return  MySQL server tablenames
function mySQL_tables($dbserver2,$dbuser2,$dbpassword2,$dbname2){
         $connect=mysql_connect($dbserver2,$dbuser2,$dbpassword2) or die("Unable to Connect");
         mysql_select_db($dbname2) or die("Authenticated, but could not open the database ".$dbname2);
         $showtablequery="SHOW TABLES FROM ".$dbname2;
         $query_result=mysql_query($showtablequery);
		 $tablenames2='';
         while($showtablerow = mysql_fetch_array($query_result))
         {
         $tablenames2 = $tablenames2.'<br/>'.$showtablerow[0];
         }
		 return $tablenames2;
}
// check responsetime for a webbserver
function mySQL_pingTime($dbserver3,$dbuser3,$dbpassword3,$dbname3){
    $starttime = microtime(true);
    // supress error messages with @
    $tablenames3 = mySQL_tables($dbserver3,$dbuser3,$dbpassword3,$dbname3);
    $stoptime  = microtime(true);
    $status    = 0;

    if ($tablenames3 == ''){
        $status = -1;  // No tables returned
    }
    else{
        $status = ($stoptime - $starttime) * 1000;
        $status = floor($status);
    }
    return $status;
}
?>
    <title></title>
</head>
<body>

<?php
echo '<div class="console">';
if (isset($_GET['dbserver'])) {
	$dbserver=$_GET["dbserver"];
	$dbuser=$_GET["dbuser"];
	$dbpassword=$_GET["dbpassword"];
	$dbname=$_GET["dbname"];
	//calulate response time and show table names
echo 'MySQL database response time: ';
echo (mySQL_pingTime($dbserver,$dbuser,$dbpassword,$dbname) / 1000);
echo ' s';
echo '<br/><br/>Table names: (for info only - not required for diagnistic data)';
echo mySQL_tables($dbserver,$dbuser,$dbpassword,$dbname);
	} else {
	echo 'Usage: pingMySQL.php?dbserver=IPADDRESS&dbuser=USER&dbpassword=PASS&dbname=NAME';
	echo '<br/>(Replace IPADDRESS with IP address of database server)';
	echo '<br/>(Replace USER with username that has permission to access the database server)';
	echo '<br/>(Replace PASS with the password)';
	echo '<br/>(Replace NAME with the name of the database)';
	}
	
?>

</body>
</html>

 


Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select at least one of the reasons
CAPTCHA verification is required.

Feedback sent

We appreciate your effort and will try to fix the article