Ignore:
Timestamp:
Mar 24, 2011, 6:50:50 AM (14 years ago)
Author:
george
Message:
  • Modified: Optimized TGList.IndexOf.
  • Used better compiler optimization level 3 for library.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Demo/UMainForm.pas

    r111 r219  
    478478var
    479479  List: TListPointer;
    480   List2: TList;
     480  List2: TFPList;
    481481  StartTime: TDateTime;
    482482  I: Integer;
     
    484484  SampleCount: Integer = 100000;
    485485begin
    486   LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TList benchmark';
     486  LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TFPList benchmark';
    487487  ListViewOutput.Clear;
    488488  try
    489489    UpdateButtonState(False);
    490490    List := TListPointer.Create;
    491     List2 := TList.Create;
    492 
    493     StartTime := Now;
    494     repeat
    495       List.Add(1);
     491    List2 := TFPList.Create;
     492
     493    WriteOutput('TListPointer.InstanceSize', IntToStr(TListPointer.InstanceSize) + ' bytes');
     494    WriteOutput('TFPList.InstanceSize', IntToStr(TFPList.InstanceSize) + ' bytes');
     495
     496    StartTime := Now;
     497    repeat
     498      List.Add(Pointer(1));
    496499    until (Now - StartTime) > MeasureDuration;
    497500    WriteOutput('TListPointer.Add', IntToStr(List.Count) + ' ops');
     
    501504    StartTime := Now;
    502505    repeat
    503       List2.Add(1);
    504     until (Now - StartTime) > MeasureDuration;
    505     WriteOutput('TList.Add', IntToStr(List2.Count) + ' ops');
     506      List2.Add(Pointer(1));
     507    until (Now - StartTime) > MeasureDuration;
     508    WriteOutput('TFPList.Add', IntToStr(List2.Count) + ' ops');
    506509    List2.Clear;
    507510    Application.ProcessMessages;
     
    509512    StartTime := Now;
    510513    repeat
    511       List.Insert(0, 1);
     514      List.Insert(0, Pointer(1));
    512515    until (Now - StartTime) > MeasureDuration;
    513516    WriteOutput('TListPointer.Insert', IntToStr(List.Count) + ' ops');
     
    517520    StartTime := Now;
    518521    repeat
    519       List2.Insert(0, 1);
    520     until (Now - StartTime) > MeasureDuration;
    521     WriteOutput('TList.Insert', IntToStr(List2.Count) + ' ops');
     522      List2.Insert(0, Pointer(1));
     523    until (Now - StartTime) > MeasureDuration;
     524    WriteOutput('TFPList.Insert', IntToStr(List2.Count) + ' ops');
    522525    List2.Clear;
    523526    Application.ProcessMessages;
    524527
    525528    for I := 0 to SampleCount - 1 do
    526       List.Add(1);
     529      List.Add(Pointer(1));
    527530    StartTime := Now;
    528531    I := 0;
     
    536539
    537540    for I := 0 to SampleCount - 1 do
    538       List2.Add(1);
     541      List2.Add(Pointer(1));
    539542    StartTime := Now;
    540543    I := 0;
     
    543546      Inc(I);
    544547    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);
     548    WriteOutput('TFPList.Delete', IntToStr(I) + ' ops');
     549    Application.ProcessMessages;
     550
     551    for I := 0 to SampleCount - 1 do
     552      List.Add(Pointer(1));
    550553    StartTime := Now;
    551554    I := 0;
     
    559562
    560563    for I := 0 to SampleCount - 1 do
    561     List2.Add(1);
     564    List2.Add(Pointer(1));
    562565    StartTime := Now;
    563566    I := 0;
     
    566569      Inc(I);
    567570    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);
     571    WriteOutput('TFPList.Move', IntToStr(I) + ' ops');
     572    Application.ProcessMessages;
     573
     574    for I := 0 to SampleCount - 1 do
     575      List.Add(Pointer(1));
    573576    StartTime := Now;
    574577    I := 0;
     
    582585
    583586    for I := 0 to SampleCount - 1 do
    584     List2.Add(1);
     587    List2.Add(Pointer(1));
    585588    StartTime := Now;
    586589    I := 0;
     
    589592      Inc(I);
    590593    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);
     594    WriteOutput('TFPList.Exchange', IntToStr(I) + ' ops');
     595    Application.ProcessMessages;
     596
     597    for I := 0 to SampleCount - 1 do
     598      List.Add(Pointer(1));
    596599    StartTime := Now;
    597600    I := 0;
     
    605608
    606609    for I := 0 to SampleCount - 1 do
    607     List2.Add(1);
     610    List2.Add(Pointer(1));
    608611    StartTime := Now;
    609612    I := 0;
     
    612615      Inc(I);
    613616    until (Now - StartTime) > MeasureDuration;
    614     WriteOutput('TList.IndexOf', IntToStr(I) + ' ops');
    615     Application.ProcessMessages;
    616 
     617    WriteOutput('TFPList.IndexOf', IntToStr(I) + ' ops');
     618    Application.ProcessMessages;
     619
     620    for I := 0 to SampleCount - 1 do
     621      List.Add(Pointer(1));
     622    StartTime := Now;
     623    I := 0;
     624    repeat
     625      List[I mod List.Count] := Pointer(1);
     626      Inc(I);
     627    until (Now - StartTime) > MeasureDuration;
     628    WriteOutput('TListPointer[I] write', IntToStr(I) + ' ops');
     629    List.Clear;
     630    Application.ProcessMessages;
     631
     632    for I := 0 to SampleCount - 1 do
     633    List2.Add(Pointer(1));
     634    StartTime := Now;
     635    I := 0;
     636    repeat
     637      List2[I mod List2.Count] := Pointer(1);
     638      Inc(I);
     639    until (Now - StartTime) > MeasureDuration;
     640    WriteOutput('TFPList[I] write', IntToStr(I) + ' ops');
     641    Application.ProcessMessages;
     642
     643    for I := 0 to SampleCount - 1 do
     644      List.Add(Pointer(1));
     645    StartTime := Now;
     646    I := 0;
     647    repeat
     648      List[I mod List.Count];
     649      Inc(I);
     650    until (Now - StartTime) > MeasureDuration;
     651    WriteOutput('TListPointer[I] read', IntToStr(I) + ' ops');
     652    List.Clear;
     653    Application.ProcessMessages;
     654
     655    for I := 0 to SampleCount - 1 do
     656    List2.Add(Pointer(1));
     657    StartTime := Now;
     658    I := 0;
     659    repeat
     660      List2[I mod List2.Count];
     661      Inc(I);
     662    until (Now - StartTime) > MeasureDuration;
     663    WriteOutput('TFPList[I] read', IntToStr(I) + ' ops');
     664    Application.ProcessMessages;
    617665  finally
    618666    UpdateButtonState(True);
Note: See TracChangeset for help on using the changeset viewer.