Time:
$arr = range(0, 1000000); // 0.6367609500885
$foo == true ? $foo = $arr : NULL; // 3.0994415283203E-06
if (true) $foo = $arr; else $foo = NULL; // 2.8610229492188E-06

PHP 5.1.6

Olafur Waage

On Sun, Dec 14, 2008 at 9:30 PM, David Grudl <da...@grudl.com> wrote:
>
> -------- Původní zpráva --------
> Od: Ilia Alshanetsky <i...@prohost.org>
>>
>> While it is slower due to the use of temp vars, in my experience unless
>> you have a few hundred operations involving ternary operator you cannot even
>> see the difference. Even then there are typically way more important areas
>> of code that need to be optimized. The only time you can really tell its
>> slower is in synthetic benchmarks.
>
> Few hundred operations involving ternary operator is nothing unusual ;)
>
>
>
> -------- Původní zpráva --------
> Od: Alexey Zakhlestin <indey...@gmail.com>
>>
>> On Sun, Dec 14, 2008 at 8:06 PM, David Grudl <da...@grudl.com> wrote:
>>  Do you have any numbers?
>>
>
> $arr = range(0, 1000000); // very very huge array
>
> $foo = true ? $arr : NULL; // 140,00 milisec
>
> if (true) $foo = $arr; else $foo = NULL; // 0,02 milisec
>
>
> DG.
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

Reply via email to