[Typo3-dev] char <-> string -> overhead -> speed

Sylvain Viart sylvain at ledragon.net
Fri Sep 24 21:55:58 CEST 2004


Hi

There is a page on the wiki about profiling :

http://wiki.typo3.org/index.php/TYPO3_sourcecode_profiling

You can add such example here. :-)

Peter Russ wrote:
> What is the benefit of $stringChar compared to stringString?

A good question. :-)

> I'm just wondering because to get similar results, either $stringChar 
> has to be defined as
> $stringChar='Test'.char(10).'newLine'; // 3
> or some high performing function as explode or strreplace or ereg has to 
> be involved.UuuOps.
> This might be an overhead.
> 
> <?php
> for($i=0;$i<$imax;$i++) $stringString="Text\nnewLine";
 >
> for($i=0;$i<$imax;$i++) $stringChar='Test'.chr(10).'newLine';
> ?>
> 
> string is about 50% more efficient.

And what about, this one ?

$nl = "\n";
$stringChar = '';
for($i=0;$i<$imax;$i++) $stringChar .= 'Test'.$nl.'newLine';

It would be great to have a lot of small example like this one and doing 
benchmark test. But we also should know about PHP internal optimization. 
I would be interesting to know PHP internal behavior on such code example ?

We should also take care about php external optimizer or cache engine. 
Because, I think it's not necessary to headache if an optimizer do all 
the stuff in behind. ;-)
-- 
Regards,
Sylvain Viart (France)
TYPO3 DocTEAM.




More information about the TYPO3-dev mailing list