Changeset 110 for Generics


Ignore:
Timestamp:
Jan 3, 2011, 7:30:09 AM (14 years ago)
Author:
george
Message:
  • Added: Disable buttons during benchmarks.
  • Modified: Benchmark duration reduced from 1 second to 100 ms.
Location:
Generics/TemplateGenerics/Demo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • Generics/TemplateGenerics/Demo/Demo.lpi

    r109 r110  
    5858        <EditorIndex Value="0"/>
    5959        <WindowIndex Value="0"/>
    60         <TopLine Value="73"/>
    61         <CursorPos X="53" Y="79"/>
     60        <TopLine Value="404"/>
     61        <CursorPos X="49" Y="419"/>
    6262        <UsageCount Value="233"/>
    6363        <Bookmarks Count="1">
     
    311311      <Unit32>
    312312        <Filename Value="../Generic/GenericList.inc"/>
    313         <EditorIndex Value="6"/>
     313        <EditorIndex Value="2"/>
    314314        <WindowIndex Value="0"/>
    315315        <TopLine Value="170"/>
     
    416416      </Unit45>
    417417      <Unit46>
    418         <Filename Value="../Specialized/SpecializedList.pas"/>
    419         <UnitName Value="SpecializedList"/>
    420         <EditorIndex Value="7"/>
    421         <WindowIndex Value="0"/>
    422         <TopLine Value="161"/>
    423         <CursorPos X="17" Y="287"/>
    424         <UsageCount Value="102"/>
    425         <Loaded Value="True"/>
    426       </Unit46>
    427       <Unit47>
    428         <Filename Value="../Generic/GenericMatrix.inc"/>
    429         <EditorIndex Value="8"/>
     418        <Filename Value="../Generic/GenericMatrix.inc"/>
     419        <EditorIndex Value="3"/>
    430420        <WindowIndex Value="0"/>
    431421        <TopLine Value="311"/>
     
    433423        <UsageCount Value="103"/>
    434424        <Loaded Value="True"/>
    435       </Unit47>
    436       <Unit48>
     425      </Unit46>
     426      <Unit47>
    437427        <Filename Value="../../../../../lazarus/trunk/lcl/graphics.pp"/>
    438428        <UnitName Value="Graphics"/>
     
    441431        <CursorPos X="37" Y="2636"/>
    442432        <UsageCount Value="90"/>
    443       </Unit48>
    444       <Unit49>
     433      </Unit47>
     434      <Unit48>
    445435        <Filename Value="../../../../../lazarus/trunk/lcl/interfaces/carbon/issues.xml"/>
    446436        <WindowIndex Value="0"/>
     
    449439        <UsageCount Value="6"/>
    450440        <DefaultSyntaxHighlighter Value="XML"/>
    451       </Unit49>
    452       <Unit50>
     441      </Unit48>
     442      <Unit49>
    453443        <Filename Value="/usr/share/fpcsrc/rtl/objpas/classes/classesh.inc"/>
    454         <EditorIndex Value="2"/>
    455444        <WindowIndex Value="0"/>
    456445        <TopLine Value="199"/>
    457446        <CursorPos X="14" Y="213"/>
    458447        <UsageCount Value="28"/>
    459         <Loaded Value="True"/>
    460       </Unit50>
    461       <Unit51>
     448      </Unit49>
     449      <Unit50>
    462450        <Filename Value="/usr/share/fpcsrc/rtl/objpas/classes/lists.inc"/>
    463         <EditorIndex Value="5"/>
    464451        <WindowIndex Value="0"/>
    465452        <TopLine Value="199"/>
    466453        <CursorPos X="3" Y="201"/>
    467454        <UsageCount Value="28"/>
    468         <Loaded Value="True"/>
     455      </Unit50>
     456      <Unit51>
     457        <Filename Value="../Generic/GenericListObject.inc"/>
     458        <WindowIndex Value="0"/>
     459        <TopLine Value="1"/>
     460        <CursorPos X="21" Y="20"/>
     461        <UsageCount Value="19"/>
    469462      </Unit51>
    470463      <Unit52>
    471         <Filename Value="../Generic/GenericListObject.inc"/>
    472         <WindowIndex Value="0"/>
    473         <TopLine Value="1"/>
    474         <CursorPos X="21" Y="20"/>
    475         <UsageCount Value="19"/>
     464        <Filename Value="/usr/share/fpcsrc/rtl/objpas/objpas.pp"/>
     465        <UnitName Value="objpas"/>
     466        <WindowIndex Value="0"/>
     467        <TopLine Value="1"/>
     468        <CursorPos X="27" Y="26"/>
     469        <UsageCount Value="28"/>
    476470      </Unit52>
    477471      <Unit53>
    478         <Filename Value="/usr/share/fpcsrc/rtl/objpas/objpas.pp"/>
    479         <UnitName Value="objpas"/>
    480         <EditorIndex Value="3"/>
    481         <WindowIndex Value="0"/>
    482         <TopLine Value="1"/>
    483         <CursorPos X="27" Y="26"/>
    484         <UsageCount Value="28"/>
    485         <Loaded Value="True"/>
    486       </Unit53>
    487       <Unit54>
    488472        <Filename Value="/usr/share/fpcsrc/rtl/inc/systemh.inc"/>
    489         <EditorIndex Value="4"/>
    490473        <WindowIndex Value="0"/>
    491474        <TopLine Value="381"/>
    492475        <CursorPos X="3" Y="398"/>
    493476        <UsageCount Value="28"/>
    494         <Loaded Value="True"/>
    495       </Unit54>
    496       <Unit55>
     477      </Unit53>
     478      <Unit54>
    497479        <Filename Value="/usr/share/fpcsrc/rtl/inc/varianth.inc"/>
    498480        <WindowIndex Value="0"/>
     
    500482        <CursorPos X="10" Y="503"/>
    501483        <UsageCount Value="7"/>
    502       </Unit55>
    503       <Unit56>
     484      </Unit54>
     485      <Unit55>
    504486        <Filename Value="../../../../../lazarus/trunk/lcl/include/control.inc"/>
    505         <EditorIndex Value="1"/>
    506487        <WindowIndex Value="0"/>
    507488        <TopLine Value="2270"/>
    508489        <CursorPos X="22" Y="2273"/>
    509490        <UsageCount Value="19"/>
    510         <Loaded Value="True"/>
    511       </Unit56>
    512       <Unit57>
     491      </Unit55>
     492      <Unit56>
    513493        <Filename Value="../Specialized/SpecializedMatrix.pas"/>
    514494        <UnitName Value="SpecializedMatrix"/>
    515         <EditorIndex Value="9"/>
     495        <EditorIndex Value="4"/>
    516496        <WindowIndex Value="0"/>
    517497        <TopLine Value="31"/>
     
    519499        <UsageCount Value="18"/>
    520500        <Loaded Value="True"/>
     501      </Unit56>
     502      <Unit57>
     503        <Filename Value="../ReadMe.txt"/>
     504        <WindowIndex Value="0"/>
     505        <TopLine Value="1"/>
     506        <CursorPos X="28" Y="10"/>
     507        <UsageCount Value="9"/>
     508        <DefaultSyntaxHighlighter Value="None"/>
    521509      </Unit57>
    522510      <Unit58>
    523         <Filename Value="../ReadMe.txt"/>
    524         <WindowIndex Value="0"/>
    525         <TopLine Value="1"/>
    526         <CursorPos X="28" Y="10"/>
    527         <UsageCount Value="9"/>
    528         <DefaultSyntaxHighlighter Value="None"/>
     511        <Filename Value="../../../../../Programy/Lazarus/fpc/2.4.3/source/rtl/objpas/dateutil.inc"/>
     512        <EditorIndex Value="1"/>
     513        <WindowIndex Value="0"/>
     514        <TopLine Value="38"/>
     515        <CursorPos X="3" Y="50"/>
     516        <UsageCount Value="10"/>
     517        <Loaded Value="True"/>
    529518      </Unit58>
    530519    </Units>
     
    623612      </Position23>
    624613      <Position24>
    625         <Filename Value="/usr/share/fpcsrc/rtl/objpas/classes/lists.inc"/>
    626         <Caret Line="679" Column="23" TopLine="677"/>
     614        <Filename Value="../Generic/GenericList.inc"/>
     615        <Caret Line="193" Column="31" TopLine="180"/>
    627616      </Position24>
    628617      <Position25>
    629618        <Filename Value="../Generic/GenericList.inc"/>
    630         <Caret Line="193" Column="31" TopLine="180"/>
     619        <Caret Line="184" Column="20" TopLine="170"/>
    631620      </Position25>
    632621      <Position26>
    633         <Filename Value="../Specialized/SpecializedList.pas"/>
    634         <Caret Line="104" Column="1" TopLine="1"/>
     622        <Filename Value="../Generic/GenericList.inc"/>
     623        <Caret Line="184" Column="19" TopLine="170"/>
    635624      </Position26>
    636625      <Position27>
    637         <Filename Value="../Specialized/SpecializedList.pas"/>
    638         <Caret Line="296" Column="1" TopLine="269"/>
     626        <Filename Value="UMainForm.pas"/>
     627        <Caret Line="42" Column="51" TopLine="20"/>
    639628      </Position27>
    640629      <Position28>
    641         <Filename Value="../Generic/GenericList.inc"/>
    642         <Caret Line="184" Column="20" TopLine="170"/>
     630        <Filename Value="UMainForm.pas"/>
     631        <Caret Line="458" Column="36" TopLine="440"/>
    643632      </Position28>
    644633      <Position29>
    645         <Filename Value="../Specialized/SpecializedList.pas"/>
    646         <Caret Line="296" Column="1" TopLine="269"/>
     634        <Filename Value="UMainForm.pas"/>
     635        <Caret Line="7" Column="52" TopLine="1"/>
    647636      </Position29>
    648637      <Position30>
    649         <Filename Value="../Generic/GenericList.inc"/>
    650         <Caret Line="184" Column="19" TopLine="170"/>
     638        <Filename Value="UMainForm.pas"/>
     639        <Caret Line="526" Column="1" TopLine="502"/>
    651640      </Position30>
    652641    </JumpHistory>
  • Generics/TemplateGenerics/Demo/UMainForm.lfm

    r109 r110  
    1010  OnCreate = FormCreate
    1111  OnDestroy = FormDestroy
    12   LCLVersion = '0.9.29'
     12  LCLVersion = '0.9.31'
    1313  object ButtonIntegerList: TButton
    1414    Left = 8
  • Generics/TemplateGenerics/Demo/UMainForm.pas

    r109 r110  
    3939  private
    4040  public
     41    MeasureDuration: TDateTime;
    4142    Bitmap: TBitmap;
     43    procedure UpdateButtonState(Enabled: Boolean);
    4244    procedure WriteOutput(Text1: string = ''; Text2: string = '');
    4345  end;
     
    5456procedure TMainForm.FormCreate(Sender: TObject);
    5557begin
     58  MeasureDuration := 100 * OneMillisecond;
    5659end;
    5760
     
    236239  ListViewOutput.Clear;
    237240  try
     241    UpdateButtonState(False);
    238242    List := TListPointer.Create;
    239243    List2 := TList.Create;
     
    242246    repeat
    243247      List.Add(1);
    244     until (Now - StartTime) > OneSecond;
     248    until (Now - StartTime) > MeasureDuration;
    245249    WriteOutput('TListPointer.Add', IntToStr(List.Count) + ' ops/sec');
    246250    List.Clear;
     
    250254    repeat
    251255      List2.Add(1);
    252     until (Now - StartTime) > OneSecond;
     256    until (Now - StartTime) > MeasureDuration;
    253257    WriteOutput('TList.Add', IntToStr(List2.Count) + ' ops/sec');
    254258    List2.Clear;
     
    258262    repeat
    259263      List.Insert(0, 1);
    260     until (Now - StartTime) > OneSecond;
     264    until (Now - StartTime) > MeasureDuration;
    261265    WriteOutput('TListPointer.Insert', IntToStr(List.Count) + ' ops/sec');
    262266    List.Clear;
     
    266270    repeat
    267271      List2.Insert(0, 1);
    268     until (Now - StartTime) > OneSecond;
     272    until (Now - StartTime) > MeasureDuration;
    269273    WriteOutput('TList.Insert', IntToStr(List2.Count) + ' ops/sec');
    270274    List2.Clear;
     
    278282      List.Delete(0);
    279283      Inc(I);
    280     until (Now - StartTime) > OneSecond;
     284    until (Now - StartTime) > MeasureDuration;
    281285    WriteOutput('TListPointer.Delete', IntToStr(I) + ' ops/sec');
    282286    List.Clear;
     
    290294      List2.Delete(0);
    291295      Inc(I);
    292     until (Now - StartTime) > OneSecond;
     296    until (Now - StartTime) > MeasureDuration;
    293297    WriteOutput('TList.Delete', IntToStr(I) + ' ops/sec');
    294298    Application.ProcessMessages;
     
    301305      List.Move(300000, 700000);
    302306      Inc(I);
    303     until (Now - StartTime) > OneSecond;
     307    until (Now - StartTime) > MeasureDuration;
    304308    WriteOutput('TListPointer.Move', IntToStr(I) + ' ops/sec');
    305309    List.Clear;
     
    313317      List2.Move(300000, 700000);
    314318      Inc(I);
    315     until (Now - StartTime) > OneSecond;
     319    until (Now - StartTime) > MeasureDuration;
    316320    WriteOutput('TList.Move', IntToStr(I) + ' ops/sec');
    317321    Application.ProcessMessages;
     
    324328      List.Exchange(300000, 700000);
    325329      Inc(I);
    326     until (Now - StartTime) > OneSecond;
     330    until (Now - StartTime) > MeasureDuration;
    327331    WriteOutput('TListPointer.Exchange', IntToStr(I) + ' ops/sec');
    328332    List.Clear;
     
    336340      List2.Exchange(300000, 700000);
    337341      Inc(I);
    338     until (Now - StartTime) > OneSecond;
     342    until (Now - StartTime) > MeasureDuration;
    339343    WriteOutput('TList.Exchange', IntToStr(I) + ' ops/sec');
    340344    Application.ProcessMessages;
     
    347351      List.IndexOf(Pointer(I mod List.Count));
    348352      Inc(I);
    349     until (Now - StartTime) > OneSecond;
     353    until (Now - StartTime) > MeasureDuration;
    350354    WriteOutput('TListPointer.IndexOf', IntToStr(I) + ' ops/sec');
    351355    List.Clear;
     
    359363      List2.IndexOf(Pointer(I mod List2.Count));
    360364      Inc(I);
    361     until (Now - StartTime) > OneSecond;
     365    until (Now - StartTime) > MeasureDuration;
    362366    WriteOutput('TList.IndexOf', IntToStr(I) + ' ops/sec');
    363367    Application.ProcessMessages;
    364368
    365369  finally
     370    UpdateButtonState(True);
    366371    List.Free;
    367372    List2.Free;
     
    380385  ListViewOutput.Clear;
    381386  try
     387    UpdateButtonState(False);
    382388    Dictionary := TDictionaryStringString.Create;
    383389    Dictionary2 := TStringList.Create;
     
    389395      Dictionary.Add(IntToStr(I), IntToStr(I));
    390396      I := I + 1;
    391     until (Now - StartTime) > OneSecond;
     397    until (Now - StartTime) > MeasureDuration;
    392398    WriteOutput('TDictionaryStringString.Add', IntToStr(Dictionary.Count) + ' ops/sec');
    393399    Application.ProcessMessages;
     
    398404      Dictionary2.Add(IntToStr(I) + Dictionary2.NameValueSeparator + IntToStr(I));
    399405      I := I + 1;
    400     until (Now - StartTime) > OneSecond;
     406    until (Now - StartTime) > MeasureDuration;
    401407    WriteOutput('TStringList.Add', IntToStr(Dictionary2.Count) + ' ops/sec');
    402408    Application.ProcessMessages;
     
    407413      R := Dictionary.Values[IntToStr(I mod Dictionary.Count)];
    408414      I := I + 1;
    409     until (Now - StartTime) > OneSecond;
     415    until (Now - StartTime) > MeasureDuration;
    410416    WriteOutput('TDictionaryStringString.Values', IntToStr(I) + ' ops/sec');
    411417    Application.ProcessMessages;
     
    416422      R := Dictionary2.Values[IntToStr(I mod Dictionary2.Count)];
    417423      I := I + 1;
    418     until (Now - StartTime) > OneSecond;
     424    until (Now - StartTime) > MeasureDuration;
    419425    WriteOutput('TStringList.Values', IntToStr(I) + ' ops/sec');
    420426    Application.ProcessMessages;
     
    425431      R := Dictionary.Keys[I mod Dictionary.Count];
    426432      I := I + 1;
    427     until (Now - StartTime) > OneSecond;
     433    until (Now - StartTime) > MeasureDuration;
    428434    WriteOutput('TDictionaryStringString.Keys', IntToStr(I) + ' ops/sec');
    429435    Application.ProcessMessages;
     
    434440      R := Dictionary2.Names[I mod Dictionary2.Count];
    435441      I := I + 1;
    436     until (Now - StartTime) > OneSecond;
     442    until (Now - StartTime) > MeasureDuration;
    437443    WriteOutput('TStringList.Keys(Names)', IntToStr(I) + ' ops/sec');
    438444    Application.ProcessMessages;
     
    443449      R := Dictionary.Items[I mod Dictionary.Count].Value;
    444450      I := I + 1;
    445     until (Now - StartTime) > OneSecond;
     451    until (Now - StartTime) > MeasureDuration;
    446452    WriteOutput('TDictionaryStringString.Items', IntToStr(I) + ' ops/sec');
    447453    Application.ProcessMessages;
     
    452458      R := Dictionary2.ValueFromIndex[I mod Dictionary2.Count];
    453459      I := I + 1;
    454     until (Now - StartTime) > OneSecond;
     460    until (Now - StartTime) > MeasureDuration;
    455461    WriteOutput('TStringList.Items(ValueFromIndex)', IntToStr(I) + ' ops/sec');
    456462    Application.ProcessMessages;
    457463
    458464  finally
     465    UpdateButtonState(True);
    459466    Dictionary.Free;
    460467    Dictionary2.Free;
     
    494501end;
    495502
     503procedure TMainForm.UpdateButtonState(Enabled: Boolean);
     504begin
     505  ButtonBenchmarkDictionary.Enabled := Enabled;
     506  ButtonBenchmarkList.Enabled := Enabled;
     507  ButtonCharList.Enabled := Enabled;
     508  ButtonDictionaryString.Enabled := Enabled;
     509  ButtonIntegerList.Enabled := Enabled;
     510  ButtonListObject.Enabled := Enabled;
     511  ButtonMatrixInteger.Enabled := Enabled;
     512  ButtonQueueInteger.Enabled := Enabled;
     513  ButtonStringList.Enabled := Enabled;
     514end;
     515
    496516procedure TMainForm.WriteOutput(Text1: string = ''; Text2: string = '');
    497517var
Note: See TracChangeset for help on using the changeset viewer.