here are results on my home computer, VS2008 (of which the SECURE_CTL flag works)
Code:x = -802947072 a: 5.756 x = -802947072 v: 6.397 x = -802947072 d: 5.885
here are results on my home computer, VS2008 (of which the SECURE_CTL flag works)
Code:x = -802947072 a: 5.756 x = -802947072 v: 6.397 x = -802947072 d: 5.885
Code:g++ -O2 -fomit-frame-pointer -funroll-loopsGCC 4.2.3, 64-bit Linux.Code:x = -802947072 a: 10.9 x = -802947072 v: 11.27 x = -802947072 d: 11.24
I tried it 9 times, 3 each with different orders. Exact code as in the original post except changing the order in main. Using VC++ 7.1 Release build. vector wins every time no matter what I try with main. High and low examples:Code:x = -802947072 a: 11.406 x = -802947072 v: 10.157 x = -802947072 d: 10.359I ran this main and got the results below:Code:x = -802947072 d: 10.281 x = -802947072 v: 9.687 x = -802947072 a: 10.094Code:{ V v; TIME_IT(func, v); } { D d; TIME_IT(func, d); } { D d; TIME_IT(func, d); } { V v; TIME_IT(func, v); } { V v; TIME_IT(func, v); } { D d; TIME_IT(func, d); }VC++ 8.0 with _SECURE_SCL defined to 0:Code:x = -802947072 v: 10.015 x = -802947072 d: 10.328 x = -802947072 d: 10.234 x = -802947072 v: 9.907 x = -802947072 v: 10.156 x = -802947072 d: 10.234The moral: there's little to no difference in speed. Meanwhile, look how easy it is to write the class with vector, and how easy it is to write a class with incorrect copy semantics with new[]/delete[].Code:x = -802947072 d: 9.718 x = -802947072 v: 9.656 x = -802947072 v: 9.688 x = -802947072 d: 9.5 x = -802947072 d: 9.578 x = -802947072 v: 9.735
No idea why, but here are my results ( VS2008 )
Release Build with full optimization.
I don't understand why the results are so nutty.Code:x = ... a: 11.969 x = ... v: 113.64 x = ... d: 18.359
Intel Centrino Duo 1.6ghz processor, I would think it would be much faster than that.
edit: that is with #define _SECURE_SCL 0
Last edited by Raigne; 11-25-2008 at 01:43 AM.
Where'd you put the #define?
My homepage
Advice: Take only as directed - If symptoms persist, please see your debugger
Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"
Compilers can produce warnings - make the compiler programmers happy: Use them!
Please don't PM me for help - and no, I don't do help over instant messengers.
I tried adding #define _SECURE_SCL 0 before all my #include directives too and that got the vector time down by a huge amount, but it was still about 50% higher than the others.
I wonder if there's a difference between VC++ retail vs VC++ express? I no longer have a professional version that I can test it with -- only the express version.
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
There shouldn't be.
All the buzzt!
CornedBee
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law
"I am probably the laziest programmer on the planet, a fact with which anyone who has ever seen my code will agree." - esbo, 11/15/2008
"the internet is a scary place to be thats why i dont use it much." - billet, 03/17/2010
For my 2005 tests I used an old project that I use for random testing. There might be some settings I've tweaked to get the output I got. You may have to turn off more microsoft extensions in the project properties.