Guest User

Untitled

a guest
Jan 13th, 2016
29
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. program project1;
  2.  
  3. {$IFDEF FPC}
  4. {$mode delphi}
  5. {$ENDIF}
  6. {$APPTYPE CONSOLE}
  7.  
  8. uses
  9. {$IFDEF FPC}
  10.   FGL
  11. {$ELSE}
  12.   System.Generics.Collections
  13. {$ENDIF},
  14.   Classes, SysUtils;
  15.  
  16. type
  17.   TMyList = class({$IFDEF FPC}TFPGMap{$ELSE}TDictionary{$ENDIF}<string, string>)
  18.   end;
  19.  
  20. const
  21.   COUNT = 5000;
  22.   FMT = 'hh:nn:ss.zzz';
  23. var
  24.   I: Integer;
  25.   B, E: TDateTime;
  26.   Name: string = '';
  27.   Value: string = '';
  28.   SL: TStrings;
  29.   LS: TMyList;
  30. begin
  31.   SL := TStringList.Create;
  32.   LS := TMyList.Create;
  33.   try
  34.     B := Now;
  35.     // add name and value
  36.     for I := 1 to COUNT do
  37.     begin
  38.       Name := IntToStr(I);
  39.       SL.Add(Name + '=' + Name);
  40.     end;
  41.     // get value from name
  42.     for I := 1 to COUNT do
  43.     begin
  44.       Name := IntToStr(I);
  45.       Value := SL.Values[Name];
  46.     end;
  47.     E := Now;
  48.     SL.Clear;
  49.     WriteLn(SL.ClassName, ': ', FormatDateTime(FMT, E - B));
  50.  
  51.     B := Now;
  52.     // add name and value
  53.     for I := 1 to COUNT do
  54.     begin
  55.       Name := IntToStr(I);
  56.       LS.Add(Name, IntToStr(I));
  57.     end;
  58.     // get value from name
  59.     for I := 1 to COUNT do
  60.     begin
  61.       Name := IntToStr(I);
  62.       Value := LS[Name];
  63.     end;
  64.     E := Now;
  65.     LS.Clear;
  66.     WriteLn(LS.ClassName, ': ', FormatDateTime(FMT, E - B));
  67.  
  68.     B := Now;
  69.     // add name and value
  70.     for I := 1 to COUNT do
  71.     begin
  72.       Name := IntToStr(I);
  73.       LS.Add(Name, IntToStr(I));
  74.     end;
  75.     // get value from name
  76.     for I := 1 to COUNT do
  77.     begin
  78.       Name := IntToStr(I);
  79.       Value := LS[Name];
  80.     end;
  81.     E := Now;
  82.     LS.Clear;
  83.     WriteLn(LS.ClassName, ': ', FormatDateTime(FMT, E - B));
  84.  
  85.     B := Now;
  86.     // add name and value
  87.     for I := 1 to COUNT do
  88.     begin
  89.       Name := IntToStr(I);
  90.       SL.Add(Name + '=' + Name);
  91.     end;
  92.     // get value from name
  93.     for I := 1 to COUNT do
  94.     begin
  95.       Name := IntToStr(I);
  96.       Value := SL.Values[Name];
  97.     end;
  98.     E := Now;
  99.     SL.Clear;
  100.     WriteLn(SL.ClassName, ': ', FormatDateTime(FMT, E - B));
  101.  
  102.     WriteLn('Press [ENTER] to exit ...');
  103.     ReadLn;
  104.   finally
  105.     SL.Free;
  106.     LS.Free;
  107.   end;
  108. end.
RAW Paste Data