You are here: speed of php Echo using Benchmark_Timer « All PHP « IT news, forums, messages
speed of php Echo using Benchmark_Timer

Posted by sumeet on 10/13/93 11:26

dear friends,

i have a simple code as follows. I would like to know why a single 'echo
$str' is much slower than a echo 'echo $str[$i]'. The results are also
shown below. it shows that ex time for a single 'echo $str' is 0.000142
and for the forloop 'echo $str[$i]' is 0.000047.

include_once('Benchmark/Profiler.php');
include_once('Benchmark/Timer.php');


$str = 'Sumeet Shroff';

$benchmark_timer = new Benchmark_Timer(false);

$benchmark_timer->start();
echo $str;
$benchmark_timer->stop();

echo '<pre>';
echo $benchmark_timer->display();
echo '</pre>';

$benchmark_timer->start();
for( $i = 0; $i < strlen($str); $i++ ) {
echo $str[$i];
}
$benchmark_timer->stop();

echo '<pre>';
echo $benchmark_timer->display();
echo '</pre>';

----------------

time index ex time %
Start 1126422109.93350400 - 0.00%
Stop 1126422109.93364600 0.000142 100.00%
total - 0.000142 100.00%

Sumeet Shroff
time index ex time %
Start 1126422109.93391200 - 0.00%
Stop 1126422109.93395900 0.000047 100.00%
total - 0.000047 100.00%


Sumeet Shroff
www.prateeksha.com

 

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

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