Re: Amazing Performance Difference between vec[] and iterators

2006-07-27 Thread Andre Poenitz
Mark <[EMAIL PROTECTED]> wrote: >> Likewise, instead of >> >> for(vector::const_iterator it = v.begin(); it != v.end(); ++it) >> >> try >> >> for(vector::const_iterator it = v.begin(), end = v.end(); it != >> end; ++it) >> >> to avoid calling v.end() every time. >> > > Aren't compilers smart

Re: Amazing Performance Difference between vec[] and iterators

2006-07-19 Thread Mark
thoth39 wrote: Ulrich Lauther wrote: Paulo Matos <[EMAIL PROTECTED]> wrote: : Hi all, : I've wanted to know if there was any performance difference between : using: : for(vector::const_iterator it = v.begin(); it != v.end(); ++it) : and : for(unsigned int k = 0; k < v.size(); ++k) Try unsi

Re: Amazing Performance Difference between vec[] and iterators

2006-07-18 Thread thoth39
Ulrich Lauther wrote: > Paulo Matos <[EMAIL PROTECTED]> wrote: > : Hi all, > > : I've wanted to know if there was any performance difference between > : using: > : for(vector::const_iterator it = v.begin(); it != v.end(); ++it) > > : and > > : for(unsigned int k = 0; k < v.size(); ++k) > > Try > >

Re: Amazing Performance Difference between vec[] and iterators

2006-07-12 Thread Bernd Strieder
Hello, Paulo Matos wrote: > I got these times: > $ time ./vec > 5030 elements in array. > sum: 27665 > > real0m7.123s > user0m7.108s > sys 0m0.008s > > $ time ./vec-iter > 5030 elements in array. > sum: 27665 > > real0m4.699s > user0m4.672s > sys 0m0.020s > > Any comme

Re: Amazing Performance Difference between vec[] and iterators

2006-07-12 Thread Ulrich Lauther
Paulo Matos <[EMAIL PROTECTED]> wrote: : Hi all, : I've wanted to know if there was any performance difference between : using: : for(vector::const_iterator it = v.begin(); it != v.end(); ++it) : and : for(unsigned int k = 0; k < v.size(); ++k) Try unsigned int size = v.size(); for (unsigned i

Re: Amazing Performance Difference between vec[] and iterators

2006-07-12 Thread meht...@gmail.com
Paulo Matos wrote: > Hi all, > > I've wanted to know if there was any performance difference between > using: > for(vector::const_iterator it = v.begin(); it != v.end(); ++it) > > and > > for(unsigned int k = 0; k < v.size(); ++k) > > and it seems there is with gcc 4.1.1, using -O3, the later is al