There's one little secret I should confess to. I used mysql_unbuffered_query() (which more people should use, depending on the problem).
The same done with mysql_query looks like this - http://www.pinkgoblin.com/test/speedtest_buffered.php
The final code (replace your mysql_query(_unbuffered) as you choose);
I've moved out the CSS now to make it easier to read.PHP Code:<?php
class SpeedTest {
var $db; // Database resource
var $query; // Query resource
var $start; // Start time
function SpeedTest () {
$this->start=$this->getmicrotime();
$this->db=mysql_pconnect('localhost','user','pass'); // Enter correct values here
mysql_select_db('dbname',$this->db); // Enter correct dbname here
}
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
function fetch() {
$this->query=mysql_query('SELECT * FROM products',$this->db); // Perform query here
}
function getTime() {
return ($this->getmicrotime()-$this->start);
}
function getRow () {
if ( $row=mysql_fetch_array($this->query,MYSQL_ASSOC) )
return $row;
else
return false;
}
}
$sTest=new SpeedTest;
?>
<html>
<head>
<title>PHP Speed Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="blah.css" rel="stylesheet" type="text/css">
</head>
<body>
<?php
$sTest->fetch();
?>
<p><b>Query Took: <?php print ($sTest->getTime()); ?></b></p>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr class="box1">
<td>productID</td>
<td>productName</td>
<td>supplierID</td>
<td>categoryID</td>
<td>quantityPerUnit</td>
<td>unitPrice</td>
<td>unitsInStock</td>
<td>unitsOnOrder</td>
<td>reorderLevel</td>
<td>discontinued</td>
</tr>
<?php
while ( $row=$sTest->getRow() ) {
?>
<tr>
<td><?php print ( $row['PRODUCTID']); ?></td>
<td><?php print ( $row['PRODUCTNAME']); ?></td>
<td><?php print ( $row['SUPPLIERID']); ?></td>
<td><?php print ( $row['CATEGORYID']); ?></td>
<td><?php print ( $row['QUANTITYPERUNIT']); ?></td>
<td><?php print ( $row['UNITPRICE']); ?></td>
<td><?php print ( $row['UNITSINSTOCK']); ?></td>
<td><?php print ( $row['UNITSONORDER']); ?></td>
<td><?php print ( $row['REORDERLEVEL']); ?></td>
<td><?php print ( $row['DISCONTINUED']); ?></td>
</tr>
<?php
}
?>
<p><b>Page Took: <?php print ( $sTest->getTime() ); ?></b></p>
</table>
</body>
</html>
One thing I'd like to see D add is another of these;
...which is placed at the end of the page after the table building is done.Code:<ASP:Label id="endLoadTime" runat="server" Text="Loading..."></ASP:Label>
Better yet would be placing VB directly at the bottom, if possible, to guarantee it gets executed at the very last: I'm not convinced by the trace output.
If anyone wants to try an ASP.NET to MySQL, recommend using one of these http://www.mysql.com/downloads/api-dotnet.html not ODBC.








Bookmarks