multiple write vs. concatenate
- OB
- Output Buffer as in ob_start()
- concat
- concatenate as in $start . $end
| OB writes | OB concat | file writes | file concat |
|---|---|---|---|
| 0.000024 | 0.000012 | 0.000150 | 0.000059 |
| 0.000021 | 0.000011 | 0.000212 | 0.000095 |
| 0.000025 | 0.000012 | 0.000203 | 0.000088 |
| 0.000027 | 0.000013 | 0.000216 | 0.000091 |
| OB writes | OB concat | file writes | file concat |
|---|---|---|---|
| 0.000020 | 0.000012 | 0.000205 | 0.000280 |
| 0.000050 | 0.000014 | 0.000246 | 0.000092 |
| 0.000022 | 0.000012 | 0.000157 | 0.000091 |
| 0.000022 | 0.000011 | 0.000212 | 0.000094 |
The timer was taken from http://www.developertutorials.com/tutorials/php/php-script-timer-051013/page1.html
<?php
print date("H:i:s"); print "<br />";
$lorem = "<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. In in nunc. Ut odio tortor, pellentesque condimentum, sollicitudin hendrerit, fermentum ac, mi. Mauris lobortis molestie sapien. Sed ac nibh. Donec sodales dictum nulla. In tempor purus ac odio. Etiam facilisis elementum dui. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Praesent in nulla vitae odio rhoncus dapibus. Quisque facilisis tortor nec lorem. Pellentesque gravida vehicula diam. Donec pharetra, libero non sollicitudin laoreet, mi ante sodales eros, vel blandit odio erat quis velit. Donec gravida nisi vel lorem. Proin pede risus, congue ac, ornare eu, aliquam sit amet, lacus. Praesent dapibus enim vel elit. Nunc turpis. In euismod, ante quis volutpat varius, neque arcu viverra nunc, vulputate convallis sapien neque quis turpis. Donec elementum. Etiam urna. Curabitur est.</p>";$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;echo $lorem;
echo $lorem;
echo $lorem;
echo $lorem;$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
//echo 'This page was created in ';
printf("%01.6f", $totaltime);
echo ' seconds.';
print "<br />";$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;echo $lorem . $lorem . $lorem . $lorem;
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
//echo 'This page was created in ';
printf("%01.6f", $totaltime);
echo ' seconds.';
print "<br />";$fp = fopen('archives/test.txt', 'a+');
$fp2 = fopen('archives/test2.txt', 'a+');$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;fwrite($fp, $lorem);
fwrite($fp, PHP_EOL);
fwrite($fp, $lorem);
fwrite($fp, PHP_EOL);
fwrite($fp, $lorem);
fwrite($fp, PHP_EOL);
fwrite($fp, $lorem);
fwrite($fp, PHP_EOL);$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
//echo 'This page was created in ';
printf("%01.6f", $totaltime);
echo ' seconds.';
print "<br />";$mtime = microtime();
$mtime = explode(' ', $mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;fwrite($fp2, $lorem . PHP_EOL . $lorem . PHP_EOL . $lorem . PHP_EOL . $lorem . PHP_EOL);
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$endtime = $mtime;
$totaltime = ($endtime - $starttime);
//echo 'This page was created in ';
printf("%01.6f", $totaltime);
echo ' seconds.';
print "<br />";?>
