# zorglub_olsen@xxxxxxxxxxx / 2006-12-21 03:33:36 +0100: > On Wednesday 20 December 2006 13:37, Roman Neuhauser wrote: > > # zorglub_olsen@xxxxxxxxxxx / 2006-12-19 19:05:23 +0100: > >> What major compelling reasons do I have to start using exceptions and > >> OOP-5? > >> What about performance? > > > > Did you measure the performance impact of all those if/else's? > > > > Exceptions are a special channel for errors, so your question is kind of > > like "is stderr any good? what about performance?" > > > If two different ways of doing the same thing seem very similar, performance > may help me choose. It's true that I don't know anything about the speed of > all my nested if/elses, but that's not necessarily relevant if others can > tell me that exceptions are always hopelessly slow. They won't be able to tell you what impact using exceptions would have on your code. > > How about iterators? You can have objects that look like arrays yet they > > take much less memory: > > > > $rs = $db->query($select); # query the db > > foreach ($rs as $row) { # fetch the row > > whatever($row); > > } > > "takes much less memory" is exactly the kind of advice I'm looking for. Don't get too excited, please. I'm not promising you'll be able to squeeze your CMS into 640KB. You're concentrating on the wrong thing. Development time is way more expensive than cpu power. I like to use typed parameters and access specifiers because they're a very concise form of documentation, and this documentation never lags behind the code! I like to use exceptions, because they allow me to write safer and more elegant code. Performance benefits? Sure, they're development boosters. What about performance? When PHP 4.0 came out, CPUs had 500MHz (IIRC), when PHP 5.2 came out, CPUs are at 4GHz. There go your microbenchmarks. > I've found very few usable guides to such optimizations. Could you > possibly give me a specific example of an array and a similar object > with this great difference in memory consumptions? Anywhere you can replace a sufficiently large aggregate structure with an iterator. They can be used as generators (c. f. python 2.5), and I'd call e. g. DirectoryIterator from SPL a generator. -- How many Vietnam vets does it take to screw in a light bulb? You don't know, man. You don't KNOW. Cause you weren't THERE. http://bash.org/?255991 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php