Re: Performance: While or For loop

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.          |
`------------------------------------------------------------'

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux