Advertisement
Guest User

Untitled

a guest
Dec 16th, 2013
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.89 KB | None | 0 0
  1. program Project1;
  2.  
  3. {$APPTYPE CONSOLE}
  4.  
  5. uses
  6.   SysUtils,
  7.   Classes,
  8.   Windows,
  9.   Generics.Collections,
  10.   Generics.Defaults;
  11.  
  12. var
  13.   Dict : TDictionary<String, Boolean>;
  14.   List : TStringList;
  15.   TC : Cardinal;
  16.   i : integer;
  17.   b : Boolean;
  18. begin
  19.   List := TStringList.Create;
  20.   Dict := TDictionary<String, Boolean>.Create();
  21.  
  22.   TC := GetTickCount();
  23.   List.LoadFromFile('test.txt');
  24.  
  25.   Writeln(Format('Reading file speed: %d ms.', [GetTickCount() - TC]));
  26.   TC := GetTickCount();
  27.  
  28.   for i := 0 to List.Count - 1 do
  29.   begin
  30.     Dict.Add(List[i], True);
  31.   end;
  32.  
  33.   Writeln(Format('Adding to the dictionary: %d ms.', [GetTickCount() - TC]));
  34.   TC := GetTickCount();
  35.  
  36.   for i := 0 to List.Count - 1 do
  37.   begin
  38.     b := Dict[List[i]];
  39.     if not b
  40.       then Break;
  41.   end;
  42.  
  43.   Writeln(Format('Dictionary reading: %d ms.', [GetTickCount() - TC]));
  44.  
  45.   List.Free;
  46.   Dict.Free;
  47. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement