');
}
}
else if(isset($_POST['unsetup']) && $_POST['unsetup'])
{
$dbcnx = mysqli_connect($host, $user, $pass, false, $port);
mysqli_select_db($dbcnx, $db);
$sql = 'DROP TABLE IF EXISTS `mquirk_table1`';
mysqli_query($dbcnx, $sql) or die(mysqli_error($dbcnx));
echo('Test table dropped.
');
}
else if(isset($_POST['benchmark']) && $_POST['benchmark'])
{
$dbcnx = mysqli_connect($host, $user, $pass, false, $port);
mysqli_select_db($dbcnx, $db);
set_time_limit(6000);
$time = microtime(true);
for($x=0;$x<100;$x++)
{
$sql = 'SELECT id, bid, cid, enum1, bool1, bool2, bool3,
magic_blob # unrequired null blob increases performance
FROM mquirk_table1
WHERE bool3 = 1
ORDER BY stamp DESC
LIMIT 0, 100';
if(!mysqli_query($dbcnx, $sql))
{
die(mysqli_error($dbcnx));
}
$sql = 'RESET QUERY CACHE';
if(!mysqli_query($dbcnx, $sql))
{
die(mysqli_error($dbcnx));
}
}
$w_time = (microtime(true) - $time);
echo('With blob: ' . (microtime(true) - $time) . '
');
$time = microtime(true);
for($x=0;$x<100;$x++)
{
$sql = 'SELECT id, bid, cid, enum1, bool1, bool2, bool3
# no magic blob
FROM mquirk_table1 t1
WHERE bool3 = 1
ORDER BY stamp DESC
LIMIT 0, 100';
if(!mysqli_query($dbcnx, $sql))
{
die(mysqli_error($dbcnx));
}
$sql = 'RESET QUERY CACHE';
if(!mysqli_query($dbcnx, $sql))
{
die(mysqli_error($dbcnx));
}
}
$wo_time = (microtime(true) - $time);
echo('Without blob: ' . (microtime(true) - $time) . '
');
echo('Difference: ' . round((($wo_time - $w_time)/$w_time)*100, 2) . '%
');
}
else
{
?>
Setting up the test data should take no longer than 15 seconds.
Benchmarking Should take no longer than 30 seconds.
Ensure you don't coincidentally have a table called 'mquirk_table1' before dropping it :P - L0cky