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
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
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
>
>
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
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
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