Ignore:
Timestamp:
Sep 8, 2012, 9:28:39 PM (12 years ago)
Author:
chronos
Message:
  • Updated: Component versions.
  • Added: Missing forms.
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        33backup
        44tunneler.exe
         5heaptrclog.trc
  • trunk/Components/TemplateGenerics

    • Property svn:ignore set to
      lib
  • trunk/Components/TemplateGenerics/Demo/UMainForm.pas

    r29 r30  
    88  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
    99  ComCtrls, SpecializedList, SpecializedDictionary, SpecializedQueue,
    10   DateUtils, SpecializedMatrix;
     10  DateUtils, SpecializedMatrix, SpecializedStream;
    1111
    1212type
     
    1515
    1616  TMainForm = class(TForm)
     17    ButtonStreamByte: TButton;
    1718    ButtonBenchmarkDictionary: TButton;
    1819    ButtonBenchmarkListPointer: TButton;
     
    3839    procedure ButtonQueueIntegerClick(Sender: TObject);
    3940    procedure ButtonStringListClick(Sender: TObject);
     41    procedure ButtonStreamByteClick(Sender: TObject);
    4042    procedure FormCreate(Sender: TObject);
    4143    procedure FormDestroy(Sender: TObject);
    42   private
    4344  public
    4445    MeasureDuration: TDateTime;
     
    6566var
    6667  List: TListInteger;
     68  List2: TListInteger;
    6769  I: Integer;
    6870begin
     
    7072  LabelTestName.Caption := 'TListInteger test';
    7173  List := TListInteger.Create;
     74  List2 := TListInteger.Create;
    7275  with List do try
    7376    AddArray([10, 20, 30, 40]);
     
    8689    Insert(5, 11);
    8790    WriteOutput('Insert(5, 11)', Implode(',', IntToStr));
     91    DeleteItems(0, 10);
     92    WriteOutput('Delete(0, 10)', Implode(',', IntToStr));
     93    List2.SetArray([1, 0]);
     94    WriteOutput('EqualTo([6, 11])', BoolToStr(EqualTo(List2)));
     95    List2.SetArray([2, 0]);
     96    WriteOutput('EqualTo([7, 11])', BoolToStr(EqualTo(List2)));
     97    InsertCount(0, 3);
     98    WriteOutput('InsertCount(0, 3)', Implode(',', IntToStr));
     99    Fill(0, 3, 9);
     100    WriteOutput('Fill(0, 3, 9)', Implode(',', IntToStr));
    88101  finally
    89102    Free;
     103    List2.Free;
    90104  end;
    91105end;
     
    110124    WriteOutput('Clear', '[' + Implode('; ', ', ', IntToStr) + ']');
    111125    WriteOutput('Count [Y, X]', IntToStr(Count.Y) + ', ' + IntToStr(Count.X));
     126  finally
     127    Free;
     128  end;
     129end;
     130
     131procedure TMainForm.ButtonStreamByteClick(Sender: TObject);
     132var
     133  Stream: TMemoryStreamByte;
     134  I: Integer;
     135  ByteArray: array of Byte;
     136  ByteArrayText: string;
     137begin
     138  ListViewOutput.Clear;
     139  LabelTestName.Caption := 'TStreamByte test';
     140  Stream := TMemoryStreamByte.Create;
     141  with Stream do try
     142    WriteOutput('Size := ', IntToStr(Stream.Size));
     143    Write(1);
     144    WriteOutput('Write(1)', '');
     145    WriteOutput('Size, Position', IntToStr(Stream.Size) + ', ' + IntToStr(Stream.Position));
     146    WriteArray([2, 3, 4]);
     147    WriteOutput('WriteArray([2, 3, 4])', '');
     148    WriteOutput('Size, Position', IntToStr(Stream.Size) + ', ' + IntToStr(Stream.Position));
     149    Position := 1;
     150    WriteOutput('Position := 1', '');
     151    WriteOutput('Size, Position', IntToStr(Stream.Size) + ', ' + IntToStr(Stream.Position));
     152    WriteOutput('Read', IntToStr(Read));
     153    WriteOutput('Size, Position', IntToStr(Stream.Size) + ', ' + IntToStr(Stream.Position));
     154    ByteArray := ReadArray(2);
     155    ByteArrayText := '[';
     156    for I := 0 to Length(ByteArray) - 1 do begin
     157      ByteArrayText := ByteArrayText + IntToStr(ByteArray[I]);
     158      if I < Length(ByteArray) - 1 then ByteArrayText := ByteArrayText + ', ';
     159    end;
     160    ByteArrayText := ByteArrayText + ']';
     161    WriteOutput('ReadArray', ByteArrayText);
     162    WriteOutput('Size, Position', IntToStr(Stream.Size) + ', ' + IntToStr(Stream.Position));
    112163  finally
    113164    Free;
     
    478529var
    479530  List: TListPointer;
    480   List2: TList;
     531  List2: TFPList;
    481532  StartTime: TDateTime;
    482533  I: Integer;
     
    484535  SampleCount: Integer = 100000;
    485536begin
    486   LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TList benchmark';
     537  LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TFPList benchmark';
    487538  ListViewOutput.Clear;
    488539  try
    489540    UpdateButtonState(False);
    490541    List := TListPointer.Create;
    491     List2 := TList.Create;
    492 
    493     StartTime := Now;
    494     repeat
    495       List.Add(1);
     542    List2 := TFPList.Create;
     543
     544    WriteOutput('TListPointer.InstanceSize', IntToStr(TListPointer.InstanceSize) + ' bytes');
     545    WriteOutput('TFPList.InstanceSize', IntToStr(TFPList.InstanceSize) + ' bytes');
     546
     547    StartTime := Now;
     548    repeat
     549      List.Add(Pointer(1));
    496550    until (Now - StartTime) > MeasureDuration;
    497551    WriteOutput('TListPointer.Add', IntToStr(List.Count) + ' ops');
     
    501555    StartTime := Now;
    502556    repeat
    503       List2.Add(1);
    504     until (Now - StartTime) > MeasureDuration;
    505     WriteOutput('TList.Add', IntToStr(List2.Count) + ' ops');
     557      List2.Add(Pointer(1));
     558    until (Now - StartTime) > MeasureDuration;
     559    WriteOutput('TFPList.Add', IntToStr(List2.Count) + ' ops');
    506560    List2.Clear;
    507561    Application.ProcessMessages;
     
    509563    StartTime := Now;
    510564    repeat
    511       List.Insert(0, 1);
     565      List.Insert(0, Pointer(1));
    512566    until (Now - StartTime) > MeasureDuration;
    513567    WriteOutput('TListPointer.Insert', IntToStr(List.Count) + ' ops');
     
    517571    StartTime := Now;
    518572    repeat
    519       List2.Insert(0, 1);
    520     until (Now - StartTime) > MeasureDuration;
    521     WriteOutput('TList.Insert', IntToStr(List2.Count) + ' ops');
     573      List2.Insert(0, Pointer(1));
     574    until (Now - StartTime) > MeasureDuration;
     575    WriteOutput('TFPList.Insert', IntToStr(List2.Count) + ' ops');
    522576    List2.Clear;
    523577    Application.ProcessMessages;
    524578
    525579    for I := 0 to SampleCount - 1 do
    526       List.Add(1);
     580      List.Add(Pointer(1));
    527581    StartTime := Now;
    528582    I := 0;
     
    536590
    537591    for I := 0 to SampleCount - 1 do
    538       List2.Add(1);
     592      List2.Add(Pointer(1));
    539593    StartTime := Now;
    540594    I := 0;
     
    543597      Inc(I);
    544598    until (Now - StartTime) > MeasureDuration;
    545     WriteOutput('TList.Delete', IntToStr(I) + ' ops');
    546     Application.ProcessMessages;
    547 
    548     for I := 0 to SampleCount - 1 do
    549       List.Add(1);
     599    WriteOutput('TFPList.Delete', IntToStr(I) + ' ops');
     600    Application.ProcessMessages;
     601
     602    for I := 0 to SampleCount - 1 do
     603      List.Add(Pointer(1));
    550604    StartTime := Now;
    551605    I := 0;
     
    559613
    560614    for I := 0 to SampleCount - 1 do
    561     List2.Add(1);
     615    List2.Add(Pointer(1));
    562616    StartTime := Now;
    563617    I := 0;
     
    566620      Inc(I);
    567621    until (Now - StartTime) > MeasureDuration;
    568     WriteOutput('TList.Move', IntToStr(I) + ' ops');
    569     Application.ProcessMessages;
    570 
    571     for I := 0 to SampleCount - 1 do
    572       List.Add(1);
     622    WriteOutput('TFPList.Move', IntToStr(I) + ' ops');
     623    Application.ProcessMessages;
     624
     625    for I := 0 to SampleCount - 1 do
     626      List.Add(Pointer(1));
    573627    StartTime := Now;
    574628    I := 0;
     
    582636
    583637    for I := 0 to SampleCount - 1 do
    584     List2.Add(1);
     638    List2.Add(Pointer(1));
    585639    StartTime := Now;
    586640    I := 0;
     
    589643      Inc(I);
    590644    until (Now - StartTime) > MeasureDuration;
    591     WriteOutput('TList.Exchange', IntToStr(I) + ' ops');
    592     Application.ProcessMessages;
    593 
    594     for I := 0 to SampleCount - 1 do
    595       List.Add(1);
     645    WriteOutput('TFPList.Exchange', IntToStr(I) + ' ops');
     646    Application.ProcessMessages;
     647
     648    for I := 0 to SampleCount - 1 do
     649      List.Add(Pointer(1));
    596650    StartTime := Now;
    597651    I := 0;
     
    605659
    606660    for I := 0 to SampleCount - 1 do
    607     List2.Add(1);
     661    List2.Add(Pointer(1));
    608662    StartTime := Now;
    609663    I := 0;
     
    612666      Inc(I);
    613667    until (Now - StartTime) > MeasureDuration;
    614     WriteOutput('TList.IndexOf', IntToStr(I) + ' ops');
    615     Application.ProcessMessages;
    616 
     668    WriteOutput('TFPList.IndexOf', IntToStr(I) + ' ops');
     669    Application.ProcessMessages;
     670
     671    for I := 0 to SampleCount - 1 do
     672      List.Add(Pointer(1));
     673    StartTime := Now;
     674    I := 0;
     675    repeat
     676      List[I mod List.Count] := Pointer(1);
     677      Inc(I);
     678    until (Now - StartTime) > MeasureDuration;
     679    WriteOutput('TListPointer[I] write', IntToStr(I) + ' ops');
     680    List.Clear;
     681    Application.ProcessMessages;
     682
     683    for I := 0 to SampleCount - 1 do
     684    List2.Add(Pointer(1));
     685    StartTime := Now;
     686    I := 0;
     687    repeat
     688      List2[I mod List2.Count] := Pointer(1);
     689      Inc(I);
     690    until (Now - StartTime) > MeasureDuration;
     691    WriteOutput('TFPList[I] write', IntToStr(I) + ' ops');
     692    Application.ProcessMessages;
     693
     694    for I := 0 to SampleCount - 1 do
     695      List.Add(Pointer(1));
     696    StartTime := Now;
     697    I := 0;
     698    repeat
     699      List[I mod List.Count];
     700      Inc(I);
     701    until (Now - StartTime) > MeasureDuration;
     702    WriteOutput('TListPointer[I] read', IntToStr(I) + ' ops');
     703    List.Clear;
     704    Application.ProcessMessages;
     705
     706    for I := 0 to SampleCount - 1 do
     707    List2.Add(Pointer(1));
     708    StartTime := Now;
     709    I := 0;
     710    repeat
     711      List2[I mod List2.Count];
     712      Inc(I);
     713    until (Now - StartTime) > MeasureDuration;
     714    WriteOutput('TFPList[I] read', IntToStr(I) + ' ops');
     715    Application.ProcessMessages;
    617716  finally
    618717    UpdateButtonState(True);
     
    645744    MoveItems(2, 3, 3);
    646745    WriteOutput('Implode', Implode(',', StrToStr));
     746    InsertCount(0, 3);
     747    WriteOutput('InsertCount(0, 3)', Implode(',', StrToStr));
     748    Fill(0, 3, 'Zero');
     749    WriteOutput('Fill(0, 3, ''Zero'')', Implode(',', StrToStr));
    647750  finally
    648751    Free;
Note: See TracChangeset for help on using the changeset viewer.