From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 10 Apr 2006 16:51:10 -0700 From: Roman Shaposhnick To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Good enough approximation for ape/pcc Message-ID: <20060410235110.GM28006@submarine> References: <229aaef51090aa24504f7f55d106b8c2@quanstro.net> <6.0.2.0.0.20060411100415.01cb6490@pop.monitorbm.co.nz> <200604102304.k3AN4vJN003576@haides.silverbrookresearch.com> <3e1162e60604101618u4e4ce0c1yac9f0246a116a2e5@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <3e1162e60604101618u4e4ce0c1yac9f0246a116a2e5@mail.gmail.com> User-Agent: Mutt/1.4.1i Topicbox-Message-UUID: 346423f6-ead1-11e9-9d60-3106f5b1d025 On Mon, Apr 10, 2006 at 04:18:56PM -0700, David Leimbach wrote: > Interesting example... > > SomeContainer::iterator it = SomeContainerObject.begin(); > > for (; it != SomeContainerObject.end(); ++it) > > is probably a lot faster than > > for(; it != SomeConatinerObject.end(); it++) > > And I'd bet that not much more than half of the so-called C++ > programmers out there in the world know why this is. If the punch line here is, in fact, what I think it is, then a good optimizing compiler should be able to make these two pretty close in terms of performance. I've been doing optimizing compilers at Sun for quite some time now (C/C++ and Fortran) and one thing that I constantly talk to our customers about is that in todays world of opaque CPU design they actually don't know whether 'a = a + 1;' is slower or faster than 'a++;'. So the best advice I can give them is to: 1. Express semantics, not how to generate code 2. Pick a compiler vendor you can trust. 3. Make Performance Analysis part of your debugging. Thanks, Roman.