Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (*
- Result for my environment:
- THashedStringList: 00:00:01.093
- TMyList: 00:00:00.093
- TMyList: 00:00:00.078
- THashedStringList: 00:00:01.093
- *)
- program project1;
- {$APPTYPE CONSOLE}
- uses
- System.Generics.Collections, System.Contnrs, Classes, SysUtils,
- System.IniFiles;
- type
- TMyList = class(TDictionary<string, string>)
- end;
- const
- COUNT = 100000; // 100.000
- FMT = 'hh:nn:ss.zzz';
- var
- I: Integer;
- B, E: TDateTime;
- Name: string = '';
- Value: string = '';
- SL: TStrings;
- LS: TMyList;
- begin
- SL := THashedStringList.Create;
- LS := TMyList.Create;
- try
- B := Now;
- // add name and value
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- SL.Add(Name + '=' + Name);
- end;
- // get value from name
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- Value := SL.Values[Name];
- end;
- E := Now;
- SL.Clear;
- WriteLn(SL.ClassName, ': ', FormatDateTime(FMT, E - B));
- B := Now;
- // add name and value
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- LS.Add(Name, IntToStr(I));
- end;
- // get value from name
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- Value := LS[Name];
- end;
- E := Now;
- LS.Clear;
- WriteLn(LS.ClassName, ': ', FormatDateTime(FMT, E - B));
- B := Now;
- // add name and value
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- LS.Add(Name, IntToStr(I));
- end;
- // get value from name
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- Value := LS[Name];
- end;
- E := Now;
- LS.Clear;
- WriteLn(LS.ClassName, ': ', FormatDateTime(FMT, E - B));
- B := Now;
- // add name and value
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- SL.Add(Name + '=' + Name);
- end;
- // get value from name
- for I := 1 to COUNT do
- begin
- Name := IntToStr(I);
- Value := SL.Values[Name];
- end;
- E := Now;
- SL.Clear;
- WriteLn(SL.ClassName, ': ', FormatDateTime(FMT, E - B));
- WriteLn('Press [ENTER] to exit ...');
- ReadLn;
- finally
- SL.Free;
- LS.Free;
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement