You are here: Re: Newline « PHP Programming Language « IT news, forums, messages
Re: Newline

Posted by Carl Vondrick on 04/14/06 00:30

Andy Jeffries wrote:
> Anyway, my point was - undeniably faster, but how much so...  Anyone got
> numbers?
In large numbers, it is significant. Ran under Kubuntu Linux with PHP 5.1.2
with 1GB RAM and 3.2Ghz processor:

Output:
S Diff: 11.428... (single quotes)
D Diff: 19.623... (double quotes)

Script:
<?php
$s_start = microtime(true);

for ($x = 0; $x < 99999; $x++)
{
echo 'Hello. How are you?<br />';
}

$s_end = microtime(true);

$d_start = microtime(true);

for ($x = 0; $x < 99999; $x++)
{
echo "Hello. How are you?<br />";
}

$d_end = microtime(true);

echo 'S Diff: ' . ($s_end - $s_start) . '<br />';
echo 'D Diff: ' . ($d_end - $d_start) . '<br />';
?>


So, single quotes wins hands down. To compare echo vs print:

Output:
E Diff: 12.626... (echo)
P Diff: 15.637... (print)

<?php
$e_start = microtime(true);

for ($x = 0; $x < 99999; $x++)
{
echo 'Hello. How are you?<br />';
}

$e_end = microtime(true);

$p_start = microtime(true);

for ($x = 0; $x < 99999; $x++)
{
print 'Hello. How are you?<br />';
}

$p_end = microtime(true);

echo 'E Diff: ' . ($e_end - $e_start) . '<br />';
echo 'P Diff: ' . ($p_end - $p_start) . '<br />';
?>

The fastest is echo with single quotes.

--
Carl Vondrick
Web-Engineer
www.carlsoft.net

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация