Changeset 78 for Generics/TemplateGenerics/Demo/UMainForm.pas
- Timestamp:
- Oct 30, 2010, 6:39:12 PM (14 years ago)
- Location:
- Generics/TemplateGenerics/Demo
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Demo
- Property svn:ignore
-
old new 1 1 lib 2 2 Demo.exe 3 heaptrclog.trc 4 Demo
-
- Property svn:ignore
-
Generics/TemplateGenerics/Demo/UMainForm.pas
r76 r78 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 9 ComCtrls, ListInteger, ListString, DictionaryString, QueueInteger, ListChar, 10 ListPointer, DateUtils, ListVariant ;10 ListPointer, DateUtils, ListVariant, Contnrs, ListObject; 11 11 12 12 type … … 15 15 16 16 TMainForm = class(TForm) 17 ButtonListObject: TButton; 17 18 ButtonBenchmark: TButton; 18 19 ButtonCharList: TButton; … … 26 27 procedure ButtonDictionaryStringClick(Sender: TObject); 27 28 procedure ButtonIntegerListClick(Sender: TObject); 29 procedure ButtonListObjectClick(Sender: TObject); 28 30 procedure ButtonQueueIntegerClick(Sender: TObject); 29 31 procedure ButtonStringListClick(Sender: TObject); … … 71 73 MoveItems(3, 2, 3); 72 74 WriteLn('Implode: ' + Implode(',', IntToStr)); 75 finally 76 Free; 77 end; 78 end; 79 80 function ObjectToStr(Obj: TObject): string; 81 begin 82 Result := Obj.ClassName; 83 end; 84 85 procedure TMainForm.ButtonListObjectClick(Sender: TObject); 86 var 87 List: TListObject; 88 I: Integer; 89 begin 90 MemoOutput.Clear; 91 WriteLn('TListObject test'); 92 List := TListObject.Create; 93 with List do try 94 AddArray([TObject.Create, TObject.Create, TObject.Create, TObject.Create]); 95 WriteLn('Implode: ' + Implode(',', ObjectToStr)); 96 Clear; 97 for I := 0 to 10 do Add(TObject.Create); 98 WriteLn('Implode: ' + Implode(',', ObjectToStr)); 99 WriteLn('Count: ' + IntToStr(Count)); 100 WriteLn('Implode: ' + Implode(',', ObjectToStr)); 101 WriteLn('Reverse'); 102 Reverse; 103 WriteLn('Implode: ' + Implode(',', ObjectToStr)); 104 MoveItems(3, 2, 3); 105 WriteLn('Implode: ' + Implode(',', ObjectToStr)); 73 106 finally 74 107 Free; … … 207 240 List.Clear; 208 241 242 for I := 0 to 1000000 do 243 List.Add(1); 244 StartTime := Now; 245 I := 0; 246 repeat 247 List.Exchange(300000, 700000); 248 Inc(I); 249 until (Now - StartTime) > OneSecond; 250 WriteLn('Exchange: ' + IntToStr(I) + ' ops/sec'); 251 List.Clear; 252 253 for I := 0 to 1000000 do 254 List.Add(1); 255 StartTime := Now; 256 I := 0; 257 repeat 258 List.IndexOf(Pointer(I mod List.Count)); 259 Inc(I); 260 until (Now - StartTime) > OneSecond; 261 WriteLn('IndexOf: ' + IntToStr(I) + ' ops/sec'); 262 List.Clear; 209 263 finally 210 264 List.Free; … … 238 292 WriteLn('Delete: ' + IntToStr(I) + ' ops/sec'); 239 293 240 241 294 for I := 0 to 1000000 do 295 List2.Add(1); 242 296 StartTime := Now; 243 297 I := 0; … … 247 301 until (Now - StartTime) > OneSecond; 248 302 WriteLn('Move: ' + IntToStr(I) + ' ops/sec'); 303 304 for I := 0 to 1000000 do 305 List2.Add(1); 306 StartTime := Now; 307 I := 0; 308 repeat 309 List2.Exchange(300000, 700000); 310 Inc(I); 311 until (Now - StartTime) > OneSecond; 312 WriteLn('Exchange: ' + IntToStr(I) + ' ops/sec'); 313 314 for I := 0 to 1000000 do 315 List2.Add(1); 316 StartTime := Now; 317 I := 0; 318 repeat 319 List2.IndexOf(Pointer(I mod List.Count)); 320 Inc(I); 321 until (Now - StartTime) > OneSecond; 322 WriteLn('IndexOf: ' + IntToStr(I) + ' ops/sec'); 249 323 250 324 finally
Note:
See TracChangeset
for help on using the changeset viewer.