Re: [PHP] Performance: While or For loop



On Sat, 2007-03-24 at 10:21 -0400, tedd wrote:
At 7:47 PM -0500 3/23/07, Richard Lynch wrote:
Folks:

How often do you use a loop of any kind in PHP with enough iterations
that this is even significant?

Write the code that makes sense.

Optimize the biggest bottleneck until performance is acceptable.

Absolutely -- the time we take discussing these types of concerns
probably cost more cycles than the sum total of all the "optimized"
savings in the lifetime of all the computers on earth.

I highly doubt it. Computers run a lot these days. There are times when
squeezing that last nanosecond makes a difference and the devotion to
finding how to squeeze it out is well worth it. Admittedly they may be
few and far between, but they do exist.

The time you spend trying to make something faster in those terms
clearly cost more time in development and maintenance. It's a
trade-off that's not worth it.

The time you spend can be large, but here we all know now how to speed
things up, if we just apply the principles that are easy to apply in all
the code we write, then such things will already be optimal and so in
hindsight we will already be reaping the rewards without any extra
effort.

Q: Do they teach this stuff in college now or are the teachers still
only measuring performance in myopic terms of saving memory and time?
Not a criticism, just a question.

They generally teach algorithmic analysis that improves the algorithm's
order of magnitude in contrast to teaching constant multiplicative
gains. However, that's not to say writing efficient code isn't a good
thing. If I have an algorithm that runs in X time, I'm sure if X is 2
years and I can shrink it to x/2 then nobody will quibble about the
constant gain since it happens to be 1 year of savings. Now depending on
the calculations you're doing, shaving off a nanosecond can indeed have
a large enough impact to make it worth your time.

Cheers,
Rob.
--
..------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'
.



Relevant Pages

  • Re: [PHP] Performance: While or For loop
    ... >How often do you use a loop of any kind in PHP with enough iterations ... "while" loop. ... it's the same problem as energy savings. ... scalable system for accessing system services | ...
    (php.general)
  • Re: HBOS shares Question
    ... were worth 714.50p and today they are worth 1002p. ... sell the shares and use savings from my ICICI Hi Interest ... account or take the lot from my savings and keep the shares? ...
    (uk.finance)
  • Re: Indulgence
    ... actually exceeded my savings. ... She's worth it, though. ... I actually do save my quit money and YES quitting ... Free and Healing for: ...
    (alt.support.stop-smoking)
  • PHPEclipse versus PDT
    ... I recently started playing around with Eclipse while experimenting ... with Android app development, and I wondered if it would be worth my ... while looking for a PHP plugin for it so I could try it out as a PHP ...
    (comp.lang.php)
  • Re: Upgrading PT 5.3 to 6.4 tonight
    ... upgrade download off digidesign.com and intend on installing it ... I figured the $35 upgrade fee was worth ... the savings in space and time that setting up the keyboard would ... from having to midi out to another device. ...
    (rec.audio.pro)