ZitatAlles anzeigen
.................http://crazywulf.de/httpdocs# php test.php
Variante 1: 0.0212051868439 Sek.
Variante 2: 0.0224738121033 Sek.
Variante 3: 0.0760178565979 Sek.
Variante 4: 0.0848259925842 Sek.
.................http://crazywulf.de/httpdocs# php test.php
Variante 1: 0.0219719409943 Sek.
Variante 2: 0.0231111049652 Sek.
Variante 3: 0.0760490894318 Sek.
Variante 4: 0.0835380554199 Sek.
.................http://crazywulf.de/httpdocs# php test.php
Variante 1: 0.0222539901733 Sek.
Variante 2: 0.0230870246887 Sek.
Variante 3: 0.0762388706207 Sek.
Variante 4: 0.0844430923462 Sek.
PHP
<?php
$file_path = 'test.txt';
// Variante 1
$beginn = microtime(true);
$content = file_get_contents($file_path);
$dauer = microtime(true) - $beginn;
echo "Variante 1: $dauer Sek.\n";
unset($begin, $dauer, $content);
// Variante 2
$beginn = microtime(true);
$read = fopen ($file_path, 'r');
$content = fread($read, filesize($file_path));
fclose($read);
$dauer = microtime(true) - $beginn;
echo "Variante 2: $dauer Sek.\n";
unset($begin, $dauer, $content, $read);
// Variante 3
$beginn = microtime(true);
$content = file($file_path);
$dauer = microtime(true) - $beginn;
echo "Variante 3: $dauer Sek.\n";
unset($begin, $dauer, $content);
// Variante 4
$beginn = microtime(true);
$content = '';
$read = fopen ($file_path, 'r');
while(!feof($read))
{
$content .= fgets($read);
}
fclose($read);
$dauer = microtime(true) - $beginn;
echo "Variante 4: $dauer Sek.\n";
unset($begin, $dauer, $content, $read);
?>
Alles anzeigen
Dateigröße ~ 6MB