Ok, habe ich gemacht. Erstmal ein paar Dateien und mysql-eintraege erstellen:
PHP-Code:
<?php
mysql_connect('localhost','root','****');
mysql_select_db('ttt');
for($i=0; $i<100; $i++)
{
$datei =fopen("datei$i.inc.php",'w');
fwrite($datei,"<?php
print('$i<br />');
?>");
mysql_query("INSERT INTO ttt (qt) VALUES ('print(\'$i<br />\');')");
fclose($datei);
}
?>
Und dann benchmarken:
PHP-Code:
<?php
class Timer {
function getmicrotime() {
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
function starttime() {
$this->st = $this->getmicrotime();
}
function displaytime() {
$this->et = $this->getmicrotime();
return round(($this->et - $this->st), 8);
}
}
mysql_connect('localhost','root','****');
mysql_select_db('ttt');
$t =new Timer();
$t->starttime();
for($i=0; $i<100; $i++)
{
if ($m =='dateien') include("datei$i.inc.php");
else
{
$row =mysql_fetch_row(mysql_query('SELECT qt FROM ttt WHERE id='.($i+1)));
eval($row[0]);
}
}
print($t->displaytime());
?>
Ich habe ganz oft F5 gedrueckt, aber die Ergebnisse sind jewals sehr aehnlich:
Include: 0.00438595
MySQL: 0.01022792
Sieht wohl so aus, als waeren includes ganz eindeutig schneller...
Lesezeichen