On 21/05/2013 at 01:41, xxxxxxxx wrote:
Never assume, always look :-) The fact that BaseArray has methods like Push(), Insert() and Resize() tells you it's dynamic.
And about the speed: The BaseArray is not just faster, it's ridiculously fast. Really.
Here's some code I just wrote to benchmark it (as I didn't have any concrete numbers) :
void MyBench(LONG cnt)
{
GeDynamicArray<Real> dynamicArray;
c4d_misc::BaseArray<Real> baseArray;
LONG i;
LONG timer = 0;
Real x = 3.14165;
GePrint("Array Benchmark (" + LongToString(cnt) + ")");
// Push()
GePrint("GeDyamicArray::Push()...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
dynamicArray.Push(x);
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
GePrint("BaseArray::Push()...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
baseArray.Append(x);
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
// Reading
GePrint("GeDynamicArray[]...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
x = dynamicArray[i];
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
GePrint("BaseArray[]...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
x = baseArray[i];
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
// Pop()
GePrint("GeDynamicArray::Pop()...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
x = dynamicArray.Pop();
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
GePrint("BaseArray::Pop()...");
timer = GeGetTimer();
for (i = 0; i < cnt; i++)
{
x = baseArray.Pop();
}
GePrint("..." + LongToString(GeGetTimer() - timer) + " msec.");
GePrint("Array Benchmark finished.");
}
I built it using the latest Intel Compiler (version 13) as a 64 Bit Release build and ran it with different cnt values:
MyBench(10000);
MyBench(100000);
MyBench(1000000);
And here are the results (on a 27" iMac with 3.4Ghz i7 and 8GB RAM) :
10000 elements
Push [] Pop
GeDynamicArray 1 msec 0 msec 5 msec
BaseArray 0 msec 0 msec 0 msec
100000 elements
Push [] Pop
GeDynamicArray 602 msec 0 msec 602 msec
BaseArray 0 msec 0 msec 0 msec
1000000 elements
Push [] Pop
GeDynamicArray 272085 msec 0 msec 271149 msec
BaseArray 9 msec 0 msec 0 msec
By the way, GeAutoDynamicArray and GeSafeDynamicArray are even slower.