Re: & performance issues
| From: | Eric Butera | Date: | Fri, 18 Apr 2008 03:39:09 +0000 |
| Subject: | Re: & performance issues | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-273218@lists.php.net to get a copy of this message | ||
On Thu, Apr 17, 2008 at 7:10 PM, Nathan Nobbe <quickshiftin@gmail.com> wrote:
> On Thu, Apr 17, 2008 at 11:51 AM, Eric Butera <eric.butera@gmail.com> wrote:
>
> >
> >
> >
> > On Thu, Apr 17, 2008 at 12:00 PM, Nathan Nobbe <quickshiftin@gmail.com>
> wrote:
> > > On Thu, Apr 17, 2008 at 4:57 AM, Bojan Tesanovic <btesanovic@gmail.com>
> > > wrote:
> > >
> > >
> > > > in PHP5 by default Objects are passed by reference and as you can see
> at
> > > > this graph passing array by reference in PHP5 is slower
> > > >
> > > > http://nathan.moxune.com/arrayVsArrayIteratorReport.php
> > >
> > >
> > > wow, thats hilarious, thats my own chart :O ROTFL
> > >
> > > im glad somebody else thought something of it ;)
> > >
> > > -nathan
> > >
> >
> > I almost spit my water out when I saw that link directed at you.
>
> good times!
>
> > Your
> > work is famous! ;)
>
> well i do what i can :D
>
>
> > I don't have an actual answer as far as benchmarks go. I've been
> > converting all of my sites from php4 to 5 over the past 3 months
> > stripping out &'s as I go. I haven't noticed any differences myself
> > though. But then again I've been adding in type hints and visibility
> > too so I'm sure that isn't helping.
>
> yea; i hadnt thought of the overhead of adding visibility / type hinting in.
> but if im adding those, either way; the extra cost from the & can be gained
> back if theyre yanked.
>
>
> > I'm always pimping Xdebug, so just remember it will show you where
> > your real bottlenecks are instead of guessing. *shrug*
>
> xdebug is da bomb; thats what i used to build the charts from the
> performance report ;)
>
> ok, so heres what im thinking. any functions that return by reference can
> safely be changed, right? so i could do a mass replace like this
>
> find: 'function &'
> replace: 'function '
>
> note, there is a space after function in the replace. i think the only
> reason to use return by reference is when returning an object to avoid
> getting a copy back in the php4 days. the rest im thinking can be done by
> hand as time goes on. waddya all think?
>
> thx,
>
> -nathan
>
Should be ok, but that is what unit tests are for, right? ;) I only
used return by reference when returning objects. I think referencing
array inputs would be more of a challenge if there was any trickery
going on there. The return value should just be a final here you go
since the function is done at that point. Guess you'll find out when
you try it. Just make a backup first! :)