При хранении в Map'е контейнеров, по моим измерениям, имеется значительное преимущество в производительности.
X++:
static void MDL_testMapArray(Args _args)
{
Array array;
int i, key;
Map map = new Map(Types::Integer, Types::Class);
MapEnumerator me;
TimeOfDay startTime;
int getKey()
{
return xGlobal::randomPositiveInt32();
}
int getValue()
{
return xGlobal::randomPositiveInt32();
}
;
setprefix('Array class в Map');
startTime = timenow();
for (i = 1; i <= 10000; i ++)
{
array = new Array(Types::Integer);
array.value( 1, getValue());
array.value( 2, getValue());
array.value( 3, getValue());
array.value( 4, getValue());
array.value( 5, getValue());
array.value( 6, getValue());
array.value( 7, getValue());
array.value( 8, getValue());
array.value( 9, getValue());
array.value(10, getValue());
map.insert(getKey(), array);
}
me = map.getEnumerator();
while (me.moveNext())
{
key = me.currentKey();
array = me.currentValue();
}
info(strfmt('Выполнено за %1 сек.', timenow() - startTime));
}
X++:
static void MDL_testMapCon(Args _args)
{
container value;
int i, key;
Map map = new Map(Types::Integer, Types::Container);
MapEnumerator me;
TimeOfDay startTime;
int getKey()
{
return xGlobal::randomPositiveInt32();
}
int getValue()
{
return xGlobal::randomPositiveInt32();
}
;
setprefix('Container в Map');
startTime = timenow();
for (i = 1; i <= 10000; i ++)
{
value = [getValue(), getValue(), getValue(), getValue(), getValue(), getValue(), getValue(), getValue(), getValue(), getValue()];
map.insert(getKey(), value);
}
me = map.getEnumerator();
while (me.moveNext())
{
key = me.currentKey();
value = me.currentValue();
}
info(strfmt('Выполнено за %1 сек.', timenow() - startTime));
}
результат:
X++:
Array class Map
19 .
Container Map
7 .