Уничтожение значений-объектов массива TMap из FCL-STL

Вопросы программирования на Free Pascal, использования компилятора и утилит.

Модератор: Модераторы

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение java73 » 03.04.2017 09:47:55

Да надо изменить изначальный алгоритм создания массива.
1. Сгенерировать последовательный массив в миллион целых чисел, от 1 до млн.
2. Перемешать его.
3. Создать ассоциированный массив, принимая за ключ последовательно все элементы из первого массива перемешанных целых чисел.
4. Калькуляцию для чистоты эксперимента и чтения в разнобой, поиском от 1 до млн. ну понятно.
Вот тогда все три варианта, на мой взгляд, будут поставлены в равные условия.
java73
постоялец
 
Сообщения: 257
Зарегистрирован: 21.11.2013 09:08:10

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 03.04.2017 09:55:47

Код: Выделить всё
  function GetName(Value: integer): string;
  begin
    Value:=Value xor $55555555;
    Result := format('MapElementKey %10d', [Value]);
  end;

такой перемес тебя устроит?
без разницы в каком порядке искать, время на создание тебе так важно? - тоже сомневаюсь что оно сильно изменится

Добавлено спустя 6 часов 38 минут 28 секунд:
такие циферки:
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Summ of       10 elenents          55, time 0,0000115739sec
Summ of      100 elenents        5050, time 0,0000543980sec
Summ of     1000 elenents      500500, time 0,0003888890sec
Summ of    10000 elenents    50005000, time 0,0039352017sec
Summ of   100000 elenents   705082704, time 0,0428241037sec
Summ of  1000000 elenents  1784293664, time 0,4664347216sec
Summ of 10000000 elenents -2004260032, time 4,8391208111sec
Destroy 2,1296sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Summ of       10 elenents          55, time 0,0000208332sec
Summ of      100 elenents        5050, time 0,0000925924sec
Summ of     1000 elenents      500500, time 0,0007789349sec
Summ of    10000 elenents    50005000, time 0,0079860911sec
Summ of   100000 elenents   705082704, time 0,0832176011sec
Summ of  1000000 elenents  1784293664, time 0,8865739801sec
Summ of 10000000 elenents -2004260032, time 9,6678246337sec
Destroy 2,2025sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Summ of       10 elenents          55, time 0,0000266205sec
Summ of      100 elenents        5050, time 0,0000925931sec
Summ of     1000 elenents      500500, time 0,0008125004sec
Summ of    10000 elenents    50005000, time 0,0081018516sec
Summ of   100000 elenents   705082704, time 0,0959490717sec
Summ of  1000000 elenents  1784293664, time 1,0682873835sec
Summ of 10000000 elenents -2004260032, time 11,2060180982sec
Destroy 4,0417sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Summ of       10 elenents          55, time 0,0000219909sec
Summ of      100 elenents        5050, time 0,0001238426sec
Summ of     1000 elenents      500500, time 0,0013807869sec
Summ of    10000 elenents    50005000, time 0,0165509118sec
Summ of   100000 elenents   705082704, time 0,1899305789sec
Summ of  1000000 elenents  1784293664, time 2,1701394871sec
Summ of 10000000 elenents -2004260032, time 24,3136571953sec
Destroy 0,9236sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Summ of       10 elenents          55, time 0,0000254629sec
Summ of      100 elenents        5050, time 0,0001527776sec
Summ of     1000 elenents      500500, time 0,0019004634sec
Summ of    10000 elenents    50005000, time 0,0239583460sec
Summ of   100000 elenents   705082704, time 0,2863426198sec
Summ of  1000000 elenents  1784293664, time 3,3414347854sec
Summ of 10000000 elenents -2004260032, time 38,0231482268sec
Destroy 1,3414sec

1-delphi xe generics.collections
2-generics.collections
3-THashMap в качестве хэша - DelphiHashLittle
4-DMap
5-TMap
Код: Выделить всё
program genericscollections;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
{$APPTYPE CONSOLE}
uses
  generics.collections,
  sysutils;

const
  elemcount=10000000;
type
TKeyType=string;
TMyMapElement = record
  Value:integer;
end;
TMyMap = TDictionary<TKeyType, TMyMapElement>;


function GetName(value:integer):string;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  result:=format('MapElementKey %10d',[value]);
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
    10000,100000:result:=10;
1000000,10000000:result:=1;
            else result:=0;
  end;
end;

function TMapElement_Create(_value:integer):TMyMapElement;
begin
  result.Value:=_value;
end;
var
  m:TMyMap;
  i,j,k:integer;
  sum,testcount:integer;
  myTime:TDateTime;
begin
  m:=TMyMap.Create;

  for i:=1 to elemcount do
  begin
   m.add(GetName(i),TMapElement_Create(i));
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       sum:=sum+m.Items[GetName(k)].Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
end.

Код: Выделить всё
program genericscollections;
{$IFDEF FPC}{$MODE DELPHI}{$ENDIF}
{$APPTYPE CONSOLE}
uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  generics.collections,
  sysutils;

const
  elemcount=10000000;
type
TKeyType=string;
TMyMapElement = record
  Value:integer;
end;
TMyMap = TDictionary<TKeyType, TMyMapElement>;


function GetName(value:integer):string;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  result:=format('MapElementKey %10d',[value]);
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
    10000,100000:result:=10;
1000000,10000000:result:=1;
            else result:=0;
  end;
end;

function TMapElement_Create(_value:integer):TMyMapElement;
begin
  result.Value:=_value;
end;
var
  m:TMyMap;
  i,j,k:integer;
  sum,testcount:integer;
  myTime:TDateTime;
begin
  m:=TMyMap.Create;

  for i:=1 to elemcount do
  begin
   m.add(GetName(i),TMapElement_Create(i));
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       sum:=sum+m.Items[GetName(k)].Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
end.

Код: Выделить всё
program hashmaptest;
uses
  ghashmap,gutil,sysutils,Generics.Hashes;
const
  elemcount=10000000;
type
TKeyType=string;
TMyMapElement=record
  Value:integer;
end;
MyStringHash=class
  class function hash(s:TKeyType; n:longint):SizeUInt;
end;
TMyMap = specialize THashMap<TKeyType, TMyMapElement, MyStringHash>;

function MakeHash(const s:TKeyType):SizeUInt;
begin
  result:=DelphiHashLittle(@s[1],length(s)*sizeof(s[1]),0);
end;

class function MyStringHash.hash(s:TKeyType; n:longint):SizeUInt;
begin
     result:=makehash(s) mod SizeUInt(n);
end;

function GetName(value:integer):string;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  result:=format('MapElementKey %10d',[value]);
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
    10000,100000:result:=10;
1000000,10000000:result:=1;
            else result:=0;
  end;
end;

function TMapElement_Create(_value:integer):TMyMapElement;
begin
  result.Value:=_value;
end;

var
  m:TMyMap;
  i,j,k:integer;
  sum,testcount:integer;
  myTime:TDateTime;
begin
  m:=TMyMap.Create;

  for i:=1 to elemcount do
  begin
   m.Insert(GetName(i),TMapElement_Create(i));
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       sum:=sum+m.Items[GetName(k)].Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
end.

Код: Выделить всё
program hashmaptest;
{$APPTYPE CONSOLE}

uses
  decal,
  SysUtils;

const
  elemcount = 10000000;

type
  TKeyType=string;
  TMyMapElement = class
    Value: integer;
  end;
function TMapElement_Create(_value: integer): TMyMapElement;
var
  me: TMyMapElement;
begin
  me := TMyMapElement.Create;
  me.Value := _value;
  exit(me);
end;
function GetName(value:integer):TKeyType;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  result:=format('MapElementKey %10d',[value]);
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
    10000,100000:result:=10;
1000000,10000000:result:=1;
            else result:=0;
  end;
end;

var
  m: DMap;
  i,j,k,testcount: integer;
  sum: integer;
  myTime: TDateTime;
begin
  m:=DMap.Create;

  for i:=1 to elemcount do
  begin
   m.PutPair([GetName(i), TMapElement_Create(i)]);
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       Sum := Sum + TMyMapElement(getObject(m.locate([GetName(k)]))).Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
end.

Код: Выделить всё
program maptest;
uses
  gmap,gutil,sysutils;
const
  elemcount=10000000;
type
TMyMapElement = record
  Value:integer;
end;
Less=specialize TLess<string>;
TMyMap = specialize TMap<string, TMyMapElement, Less>;


function GetName(value:integer):string;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  result:=format('MapElementKey %10d',[value]);
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
    10000,100000:result:=10;
1000000,10000000:result:=1;
            else result:=0;
  end;
end;

function TMapElement_Create(_value:integer):TMyMapElement;
begin
  result.Value:=_value;
end;
var
  m:TMyMap;
  i,j,k:integer;
  sum,testcount:integer;
  myTime:TDateTime;
begin
  m:=TMyMap.Create;

  for i:=1 to elemcount do
  begin
   m.Insert(GetName(i),TMapElement_Create(i));
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       sum:=sum+m.Items[GetName(k)].Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
end.

Любопытно что скомпиленое fpc моментально раскручивает вентилятор проца на максимум, скомпиленое делфи оставляет его на минимальных оборотах

Добавлено спустя 2 часа 26 минут 8 секунд:
ключ заменен на integer
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Summ of       10 elenents          55, time 0,0000023145sec
Summ of      100 elenents        5050, time 0,0000208332sec
Summ of     1000 elenents      500500, time 0,0000787040sec
Summ of    10000 elenents    50005000, time 0,0008101779sec
Summ of   100000 elenents   705082704, time 0,0090277899sec
Summ of  1000000 elenents  1784293664, time 0,1423613867sec
Summ of 10000000 elenents -2004260032, time 1,6504629457sec
Destroy 0,1701sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Summ of       10 elenents          55, time 0,0000011576sec
Summ of      100 elenents        5050, time 0,0000138883sec
Summ of     1000 elenents      500500, time 0,0000648150sec
Summ of    10000 elenents    50005000, time 0,0004628964sec
Summ of   100000 elenents   705082704, time 0,0061342143sec
Summ of  1000000 elenents  1784293664, time 0,1168984454sec
Summ of 10000000 elenents -2004260032, time 1,4212964743sec
Destroy 0,1655sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000069442sec
Summ of     1000 elenents      500500, time 0,0000706023sec
Summ of    10000 elenents    50005000, time 0,0006944174sec
Summ of   100000 elenents   705082704, time 0,0075231947sec
Summ of  1000000 elenents  1784293664, time 0,0949075911sec
Summ of 10000000 elenents -2004260032, time 1,1574076780sec
Destroy 0,5648sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Summ of       10 elenents          55, time 0,0000011569sec
Summ of      100 elenents        5050, time 0,0000115739sec
Summ of     1000 elenents      500500, time 0,0000648150sec
Summ of    10000 elenents    50005000, time 0,0008101779sec
Summ of   100000 elenents   705082704, time 0,0144675869sec
Summ of  1000000 elenents  1784293664, time 0,2708336979sec
Summ of 10000000 elenents -2004260032, time 3,4444441553sec
Destroy 1,7731sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Summ of       10 elenents          55, time 0,0000069442sec
Summ of      100 elenents        5050, time 0,0000497690sec
Summ of     1000 elenents      500500, time 0,0005740745sec
Summ of    10000 elenents    50005000, time 0,0074074342sec
Summ of   100000 elenents   705082704, time 0,0878472201sec
Summ of  1000000 elenents  1784293664, time 1,0543983080sec
Summ of 10000000 elenents -2004260032, time 11,9351847388sec
Destroy 0,4086sec

TMap выходит в лидеры

Добавлено спустя 23 минуты 38 секунд:
Если в качестве хэша возвращать сам ключь
Код: Выделить всё
E:\zcad\other\maptests>E:\zcad\other\maptests\hashmaptest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000046297sec
Summ of     1000 elenents      500500, time 0,0000428241sec
Summ of    10000 elenents    50005000, time 0,0004628964sec
Summ of   100000 elenents   705082704, time 0,0024305336sec
Summ of  1000000 elenents  1784293664, time 0,0266205461sec
Summ of 10000000 elenents -2004260032, time 0,3043984179sec
Destroy 1,0637sec

В TMap всетаки какието проблемы, THashMap рулит
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение java73 » 03.04.2017 23:43:40

В моем случае THashMap совсем не рулит.
1. DMap
Код: Выделить всё
Summ of       10 elenents          55, time 0.0000162036sec
Summ of      100 elenents        5050, time 0.0001423614sec
Summ of     1000 elenents      500500, time 0.0016157406sec
Summ of    10000 elenents    50005000, time 0.0194444874sec
Summ of   100000 elenents   705082704, time 0.2200231393sec
Summ of  1000000 elenents  1784293664, time 2.5405090128sec
Summ of 10000000 elenents -2004260032, time 28.6145834252sec

2. DMultiMap
Код: Выделить всё
Summ of       10 elenents          55, time 0.0000173612sec
Summ of      100 elenents        5050, time 0.0001446759sec
Summ of     1000 elenents      500500, time 0.0017094906sec
Summ of    10000 elenents    50005000, time 0.0204861135sec
Summ of   100000 elenents   705082704, time 0.2237268927sec
Summ of  1000000 elenents  1784293664, time 2.5868052035sec
Summ of 10000000 elenents -2004260032, time 29.4201388897sec

3. THashMap
Код: Выделить всё
Summ of       10 elenents          55, time 0.0000474531sec
Summ of      100 elenents        5050, time 0.0004351852sec
Summ of     1000 elenents      500500, time 0.0043796295sec
Summ of    10000 elenents    50005000, time 0.0457176066sec
Summ of   100000 elenents   705082704, time 0.4778934817sec
Summ of  1000000 elenents  1784293664, time 5.0983799156sec
Summ of 10000000 elenents -2004260032, time 54.6956020116sec
java73
постоялец
 
Сообщения: 257
Зарегистрирован: 21.11.2013 09:08:10

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 04.04.2017 00:29:16

>>В моем случае THashMap совсем не рулит.
Версия компилятора? Виснет на 10e7? ну хоть циферки до этого приведи.
У меня транк месячной давности - всё ок.

а genericscollections?

Добавлено спустя 13 часов 31 минуту 56 секунд:
Ну и напоследок линейный поиск в не сортированом линейном массиве
Код: Выделить всё
program vectortest;
uses
  gvector,sysutils;
const
  elemcount=100000;
type
TKeyType={string}integer;
TMyMapElement = record
  Value:integer;
end;
generic GPair<TKey,TValue>=record
  Key:TKey;
  Value:TValue;
end;
generic GMyArray<TKey,TValue> = class(specialize TVector<specialize GPair<TKey,TValue>>)
type
   TPair=specialize GPair<TKey,TValue>;

   procedure Insert(const Key:TKey;const Value:TValue);inline;
   function GetValue(key:TKey):TValue;inline;
   property Items[i : TKey]: TValue read GetValue write Insert; default;
end;
TMyArray=specialize GMyArray<TKeyType,TMyMapElement>;

procedure GMyArray.Insert(const Key:TKey;const Value:TValue);
var
   Pair:TPair;
begin
  Pair.Key:=Key;
  Pair.Value:=Value;
  PushBack(Pair);
end;
function GMyArray.GetValue(key:TKey):TValue;
var
   i:SizeUInt;
begin
  for i:=0 to Size-1 do
    if Mutable[i]^.Key=key then
      exit(Mutable[i]^.Value)
end;
function GetName(value:integer):TKeyType;
begin
  if (value and 1)>0 then
    value:=elemcount-value;
  value:=value xor $55555555;
  //result:=format('MapElementKey %10d',[value]);
  result:=value;
end;

function NeedTestsCount(value:integer):integer;
begin
  case value of
     10,100,1000:result:=1000;
           10000:result:=10;
          100000:result:=3;
            else result:=0;
  end;
end;

function TMapElement_Create(_value:integer):TMyMapElement;
begin
  result.Value:=_value;
end;
var
  m:TMyArray;
  i,j,k:integer;
  sum,testcount:integer;
  myTime:TDateTime;
begin
  m:=TMyArray.Create;

  for i:=1 to elemcount do
  begin
   m.Insert(GetName(i),TMapElement_Create(i));
   testcount:=NeedTestsCount(i);
   if testcount>0 then
   begin
   myTime:=now;
   for j:=1 to testcount do
   begin
     sum:=0;
     for k:=1 to i do
       sum:=sum+m.Items[GetName(k)].Value;
   end;
   writeln(format('Summ of %8d elenents %11d, time %.10fsec',[i,sum,((now-myTime)/testcount)*10e4]));
   end;
  end;

  myTime:=now;
  m.Destroy;
  writeln(format('Destroy %.4fsec',[(now-myTime)*10e4]));
  readln;
end.

ключ string:
Код: Выделить всё
E:\zcad\other\maptests>E:\zcad\other\maptests\vectortest.exe
Summ of       10 elenents          55, time 0,0000162036sec
Summ of      100 elenents        5050, time 0,0003807872sec
Summ of     1000 elenents      500500, time 0,0310555552sec
Summ of    10000 elenents    50005000, time 2,9372685094sec
Summ of   100000 elenents   705082704, time 293,0848764663sec
Destroy 0,0046sec


ключ integer:
Код: Выделить всё
E:\zcad\other\maptests>E:\zcad\other\maptests\vectortest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000127315sec
Summ of     1000 elenents      500500, time 0,0003449073sec
Summ of    10000 elenents    50005000, time 0,0320601976sec
Summ of   100000 elenents   705082704, time 3,2237655735sec
Destroy 0,0000sec

Нелинейные алгоритмы выигрывают в разы уже на сотне элементов
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 07.04.2017 19:38:59

Вобщем переделал на рандомы.
Integer в качестве ключа
Время наполнения
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Fill structure 2,1204sec
Destroy 0,1377sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Fill structure 2,7882sec
Destroy 0,1655sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Fill structure 5,0602sec
Destroy 1,7211sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Fill structure 19,0324sec
Destroy 1,1759sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Fill structure 14,4456sec
Destroy 1,7373sec

E:zcadothermaptests>E:zcadothermaptestsvectortest.exe
Fill structure 0,1516sec
Destroy 0,0081sec


поиск:
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Summ of       10 elenents          55, time 0,0000023145sec
Summ of      100 elenents        5050, time 0,0000185188sec
Summ of     1000 elenents      500500, time 0,0000821761sec
Summ of    10000 elenents    50005000, time 0,0006944902sec
Summ of   100000 elenents   705082704, time 0,0071759132sec
Summ of  1000000 elenents  1784293664, time 0,1284723112sec
Summ of 10000000 elenents -2004260032, time 1,5196761524sec
Destroy 0,1377sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Summ of       10 elenents          55, time 0,0000011576sec
Summ of      100 elenents        5050, time 0,0000127315sec
Summ of     1000 elenents      500500, time 0,0000740736sec
Summ of    10000 elenents    50005000, time 0,0006944174sec
Summ of   100000 elenents   705082704, time 0,0071759132sec
Summ of  1000000 elenents  1784293664, time 0,1261578291sec
Summ of 10000000 elenents -2004260032, time 1,5046294720sec
Destroy 0,1678sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000034728sec
Summ of     1000 elenents      500500, time 0,0000347223sec
Summ of    10000 elenents    50005000, time 0,0003472087sec
Summ of   100000 elenents   705082704, time 0,0059028389sec
Summ of  1000000 elenents  1784293664, time 0,1203705324sec
Summ of 10000000 elenents -2004260032, time 1,6226847947sec
Destroy 1,7361sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Summ of       10 elenents          55, time 0,0000115746sec
Summ of      100 elenents        5050, time 0,0000590277sec
Summ of     1000 elenents      500500, time 0,0005567126sec
Summ of    10000 elenents    50005000, time 0,0070601527sec
Summ of   100000 elenents   705082704, time 0,0894675759sec
Summ of  1000000 elenents  1784293664, time 1,3009259419sec
Summ of 10000000 elenents -2004260032, time 18,3472220670sec
Destroy 1,2095sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000034721sec
Summ of     1000 elenents      500500, time 0,0000810185sec
Summ of    10000 elenents    50005000, time 0,0011573866sec
Summ of   100000 elenents   705082704, time 0,0187499973sec
Summ of  1000000 elenents  1784293664, time 0,4444445949sec
Summ of 10000000 elenents -2004260032, time 8,6064814241sec
Destroy 1,7604sec

E:zcadothermaptests>E:zcadothermaptestsvectortest.exe
Summ of       10 elenents          55, time 0,0000000000sec
Summ of      100 elenents        5050, time 0,0000162036sec
Summ of     1000 elenents      500500, time 0,0004131944sec
Summ of    10000 elenents    50005000, time 0,0320601976sec
Summ of   100000 elenents   705082704, time 3,2214506064sec
Destroy 0,0081sec


String в качестве ключа
Время наполнения
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Fill structure 6,5671sec
Destroy 2,1875sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Fill structure 17,3785sec
Destroy 2,1400sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Fill structure 20,6100sec
Destroy 3,9745sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Fill structure 45,5926sec
Destroy 2,8715sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Fill structure 100,6134sec
Destroy 3,1701sec

E:zcadothermaptests>E:zcadothermaptestsvectortest.exe
Fill structure 6,4873sec
Destroy 0,4907sec


поиск:
Код: Выделить всё
E:zcadothermaptestsdelphiDebugWin32>E:zcadothermaptestsdelphiDebugWin32genericscollections.exe
Summ of       10 elenents          55, time 0,0000092594sec
Summ of      100 elenents        5050, time 0,0000509259sec
Summ of     1000 elenents      500500, time 0,0003784728sec
Summ of    10000 elenents    50005000, time 0,0038194412sec
Summ of   100000 elenents   705082704, time 0,0405092578sec
Summ of  1000000 elenents  1784293664, time 0,4513887689sec
Summ of 10000000 elenents -2004260032, time 4,7222223657sec
Destroy 2,0741sec

E:zcadothermaptests>E:zcadothermaptestsgenericscollections.exe
Summ of       10 elenents          55, time 0,0000173612sec
Summ of      100 elenents        5050, time 0,0000891203sec
Summ of     1000 elenents      500500, time 0,0008483796sec
Summ of    10000 elenents    50005000, time 0,0087962690sec
Summ of   100000 elenents   705082704, time 0,0900463056sec
Summ of  1000000 elenents  1784293664, time 0,9537034202sec
Summ of 10000000 elenents -2004260032, time 10,2060184872sec
Destroy 2,0359sec

E:zcadothermaptests>E:zcadothermaptestshashmaptest.exe
Summ of       10 elenents          55, time 0,0000150460sec
Summ of      100 elenents        5050, time 0,0000937500sec
Summ of     1000 elenents      500500, time 0,0008634255sec
Summ of    10000 elenents    50005000, time 0,0086805085sec
Summ of   100000 elenents   705082704, time 0,0994213042sec
Summ of  1000000 elenents  1784293664, time 1,1122683645sec
Summ of 10000000 elenents -2004260032, time 11,6805560538sec
Destroy 3,7928sec

E:zcadothermaptests>E:zcadothermaptestsdmaptest.exe
Summ of       10 elenents          55, time 0,0000243053sec
Summ of      100 elenents        5050, time 0,0001180553sec
Summ of     1000 elenents      500500, time 0,0014074074sec
Summ of    10000 elenents    50005000, time 0,0171296415sec
Summ of   100000 elenents   705082704, time 0,2314815356sec
Summ of  1000000 elenents  1784293664, time 3,2789350371sec
Summ of 10000000 elenents -2004260032, time 44,6099540568sec
Destroy 2,7998sec

E:zcadothermaptests>E:zcadothermaptestsmaptest.exe
Summ of       10 elenents          55, time 0,0000231485sec
Summ of      100 elenents        5050, time 0,0001550929sec
Summ of     1000 elenents      500500, time 0,0019363426sec
Summ of    10000 elenents    50005000, time 0,0241897942sec
Summ of   100000 elenents   705082704, time 0,3186342656sec
Summ of  1000000 elenents  1784293664, time 4,4305554184sec
Summ of 10000000 elenents -2004260032, time 58,8148148381sec
Destroy 3,1794sec

E:zcadothermaptests>E:zcadothermaptestsvectortest.exe
Summ of       10 elenents          55, time 0,0000185188sec
Summ of      100 elenents        5050, time 0,0003414352sec
Summ of     1000 elenents      500500, time 0,0274317135sec
Summ of    10000 elenents    50005000, time 2,6651620283sec


Более подробное сравнение:
Код: Выделить всё
E:zcadothermaptests>TimeMem-1.0.exe genericscollections.exe
Summ of       10 elenents          55, time 0,0000243053sec
Summ of      100 elenents        5050, time 0,0000891203sec
Summ of     1000 elenents      500500, time 0,0008599534sec
Summ of    10000 elenents    50005000, time 0,0087963417sec
Summ of   100000 elenents   705082704, time 0,0930555689sec
Summ of  1000000 elenents  1784293664, time 0,9872688679sec
Summ of 10000000 elenents -2004260032, time 10,6909719761sec
Destroy 2,1412sec
Exit code      : 0
Elapsed time   : 28.98
Kernel time    : 0.31 (1.1%)
User time      : 28.63 (98.8%)
page fault #   : 257804
Working set    : 835532 KB
Paged pool     : 85 KB
Non-paged pool : 11 KB
Page file size : 842108 KB

E:zcadothermaptests>TimeMem-1.0.exe hashmaptest.exe
Summ of       10 elenents          55, time 0,0000092594sec
Summ of      100 elenents        5050, time 0,0000868051sec
Summ of     1000 elenents      500500, time 0,0008726849sec
Summ of    10000 elenents    50005000, time 0,0092592381sec
Summ of   100000 elenents   705082704, time 0,1046296529sec
Summ of  1000000 elenents  1784293664, time 1,1574076780sec
Summ of 10000000 elenents -2004260032, time 12,3831021483sec
Destroy 4,0127sec
Exit code      : 0
Elapsed time   : 35.24
Kernel time    : 0.45 (1.3%)
User time      : 34.77 (98.7%)
page fault #   : 418582
Working set    : 1609068 KB
Paged pool     : 84 KB
Non-paged pool : 17 KB
Page file size : 1629440 KB

E:zcadothermaptests>TimeMem-1.0.exe dmaptest.exe
Summ of       10 elenents          55, time 0,0000092594sec
Summ of      100 elenents        5050, time 0,0001261571sec
Summ of     1000 elenents      500500, time 0,0014375000sec
Summ of    10000 elenents    50005000, time 0,0177082984sec
Summ of   100000 elenents   705082704, time 0,2478009264sec
Summ of  1000000 elenents  1784293664, time 3,5092591133sec
Summ of 10000000 elenents -2004260032, time 48,3333336888sec
Destroy 2,9525sec
Exit code      : 0
Elapsed time   : 91.55
Kernel time    : 0.25 (0.3%)
User time      : 91.21 (99.6%)
page fault #   : 305626
Working set    : 1222260 KB
Paged pool     : 84 KB
Non-paged pool : 11 KB
Page file size : 1229540 KB

E:zcadothermaptests>TimeMem-1.0.exe maptest.exe
Summ of       10 elenents          55, time 0,0000115739sec
Summ of      100 elenents        5050, time 0,0001504632sec
Summ of     1000 elenents      500500, time 0,0019999999sec
Summ of    10000 elenents    50005000, time 0,0251157326sec
Summ of   100000 elenents   705082704, time 0,3416666732sec
Summ of  1000000 elenents  1784293664, time 4,7071756853sec
Summ of 10000000 elenents -2004260032, time 62,8668982245sec
Destroy 3,4468sec
Exit code      : 0
Elapsed time   : 158.62
Kernel time    : 0.25 (0.2%)
User time      : 158.23 (99.8%)
page fault #   : 237957
Working set    : 951600 KB
Paged pool     : 84 KB
Non-paged pool : 13 KB
Page file size : 963000 KB


Добавлено спустя 1 час 13 минут 47 секунд:
Generics.collections лучше и по скорости и по памяти
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение java73 » 07.04.2017 22:47:52

А ведь еще есть TFPGMap, совсем обделенный вниманием))

Добавлено спустя 7 минут 11 секунд:
плюс из generic.collections, портированной на фрипаскаль, есть обычный тип TDictionary
java73
постоялец
 
Сообщения: 257
Зарегистрирован: 21.11.2013 09:08:10

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 07.04.2017 23:07:35

>>TFPGMap, совсем обделенный вниманием))
уделите

>>есть обычный тип TDictionary
в тесте используется TDictionary<TKey, TValue> = class(TOpenAddressingLP<TKey, TValue>);
что за обычный тип?
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение java73 » 07.04.2017 23:33:54

Сори, не узрел.

Добавлено спустя 6 минут 20 секунд:
Вообще, включив модуль, хранящий данные в TMap, и обрабатывающий, например, трехстраничный текст, на рабочем компьютере десятилетней давности пауза - ну секунду, не больше. За эту секунду помимо прохода по массиву для подстановки значений грузится файл, первый раз считывается построчно и заполняется массив тэгами, потом из mysql генерится результ, который используется для подстановки значений в массив тэгов, и в конце отображается форма с подготовленным текстом. Я не думаю, что это ощутимая потеря в скорости))
Но ради академичности я могу запилить вторую реализацию интерфейса, ответственного за хранение массива, на generic.collections))
Мне синтаксис, приближенный к идеальному, понравился в примерах к этому самому generic.collections
java73
постоялец
 
Сообщения: 257
Зарегистрирован: 21.11.2013 09:08:10

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 08.04.2017 12:47:20

>>Мне синтаксис, приближенный к идеальному, понравился в примерах к этому самому generic.collections
Примеры стянуты отсюда - http://keeper89.blogspot.ru/2011/07/delphi-1.html там и довольно подробное описание на русском
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Re: Уничтожение значений-объектов массива TMap из FCL-STL

Сообщение zub » 31.05.2017 00:32:57

Вравнение разных реализаций с красивыми графиками
http://www.benibela.de/fpc-map-benchmark_en.html
zub
долгожитель
 
Сообщения: 2884
Зарегистрирован: 14.11.2005 23:51:26

Пред.

Вернуться в Free Pascal Compiler

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 34

Рейтинг@Mail.ru