Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Array vs Ve...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 14 Topic 9810 of 9909
Post > Topic >>

Re: Array vs Vector performance

by Francis Glassborow <francis.glassborow@[EMAIL PROTECTED] > Jul 24, 2008 at 05:15 AM

JoshuaMaurice@[EMAIL PROTECTED]
 wrote:

> Even then, as Hak...@[EMAIL PROTECTED]
 pointed out, your test is comparing
> apples to oranges. std::vector stores its elements on the heap. Your
> array is statically allocated on the stack. The vector test is getting
> the heap memory management overhead, a.k.a. new[] and delete[] calls.
> If you change your array to be new[]'ed and delete[]'ed, you should
> see comparable results. A stack array will be much quicker than
> allocating an array on the heap, as your test demonstrates. If you
> know the size of the array at compile time, then use a stack array and
> not a vector. If you need the utility of vector (such as insert,
> erase, resize, etc.), and it's not performance critical, then use a
> vector.
> 
I think if you look at his code you will find that the
construction/destruction overheads have been extracted and that the
measurements are done on existing objects.

-- 
Note that robinton.demon.co.uk addresses are no longer valid.

      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 14 Posts in Topic:
Array vs Vector performance
krisprad@[EMAIL PROTECTED  2008-07-21 04:28:16 
Re: Array vs Vector performance
"Martin T." <  2008-07-21 14:38:29 
Re: Array vs Vector performance
Mathias Gaunard <loufo  2008-07-21 14:40:18 
Re: Array vs Vector performance
Alberto Ganesh Barbati &l  2008-07-21 15:17:18 
Re: Array vs Vector performance
tni <nobody@[EMAIL PRO  2008-07-21 15:22:02 
Re: Array vs Vector performance
"Hakusa@[EMAIL PROTE  2008-07-22 15:58:15 
Re: Array vs Vector performance
Andre Poenitz <poenitz  2008-07-23 19:30:22 
Re: Array vs Vector performance
JoshuaMaurice@[EMAIL PROT  2008-07-23 19:40:18 
Re: Array vs Vector performance
krisprad@[EMAIL PROTECTED  2008-07-23 19:58:15 
Re: Array vs Vector performance
Francis Glassborow <fr  2008-07-24 05:15:51 
Re: Array vs Vector performance
Alberto Ganesh Barbati &l  2008-07-24 05:13:20 
Re: Array vs Vector performance
Mirco Wahab <wahab@[EM  2008-07-24 13:26:45 
Re: Array vs Vector performance
tni <nobody@[EMAIL PRO  2008-07-24 13:58:16 
Re: Array vs Vector performance
krisprad@[EMAIL PROTECTED  2008-07-24 17:21:53 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Aug 20 13:10:19 CDT 2008.