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
Printable View
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-loops
GCC 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.359
I ran this main and got the results below:Code:x = -802947072
d: 10.281
x = -802947072
v: 9.687
x = -802947072
a: 10.094
Code:{
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.234
The 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
Where'd you put the #define?
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.
There shouldn't be.
My results was often that the dynamic array was faster, but sometimes also slower, so I guess the results vary. Usually, it's about 10% difference in speed anyway, so not so much overhead.
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.
Really? Did you try to step through with the debugger?