Changeset 76 for Generics/TemplateGenerics/Demo/UMainForm.pas
- Timestamp:
- Oct 29, 2010, 7:49:29 AM (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 Demo.exe
-
- Property svn:ignore
-
Generics/TemplateGenerics/Demo/UMainForm.pas
r74 r76 7 7 uses 8 8 Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, 9 ComCtrls, ListInteger, ListString, DictionaryString, QueueInteger, ListChar; 9 ComCtrls, ListInteger, ListString, DictionaryString, QueueInteger, ListChar, 10 ListPointer, DateUtils, ListVariant; 10 11 11 12 type … … 14 15 15 16 TMainForm = class(TForm) 17 ButtonBenchmark: TButton; 16 18 ButtonCharList: TButton; 17 19 ButtonQueueInteger: TButton; … … 20 22 ButtonStringList: TButton; 21 23 MemoOutput: TMemo; 24 procedure ButtonBenchmarkClick(Sender: TObject); 22 25 procedure ButtonCharListClick(Sender: TObject); 23 26 procedure ButtonDictionaryStringClick(Sender: TObject); … … 28 31 procedure FormDestroy(Sender: TObject); 29 32 private 30 { private declarations }31 33 public 32 34 procedure WriteLn(Text: string); … … 86 88 Enqueue(2); 87 89 Enqueue(3); 88 WriteLn('Implode: ' + Implode(',', IntToStr));90 WriteLn('Implode: ' + List.Implode(',', IntToStr)); 89 91 WriteLn('Enqueue: 4'); 90 92 Enqueue(4); 91 WriteLn('Implode: ' + Implode(',', IntToStr));93 WriteLn('Implode: ' + List.Implode(',', IntToStr)); 92 94 WriteLn('Dequeue: ' + IntToStr(Dequeue)); 93 WriteLn('Implode: ' + Implode(',', IntToStr));95 WriteLn('Implode: ' + List.Implode(',', IntToStr)); 94 96 finally 95 97 Free; … … 158 160 end; 159 161 162 procedure TMainForm.ButtonBenchmarkClick(Sender: TObject); 163 var 164 List: TListPointer; 165 List2: TList; 166 StartTime: TDateTime; 167 I: Integer; 168 begin 169 MemoOutput.Clear; 170 try 171 List := TListPointer.Create; 172 WriteLn('TListPointer...'); 173 StartTime := Now; 174 repeat 175 List.Add(1); 176 until (Now - StartTime) > OneSecond; 177 WriteLn('Add: ' + IntToStr(List.Count) + ' ops/sec'); 178 List.Clear; 179 180 StartTime := Now; 181 repeat 182 List.Insert(0, 1); 183 until (Now - StartTime) > OneSecond; 184 WriteLn('Insert: ' + IntToStr(List.Count) + ' ops/sec'); 185 List.Clear; 186 187 for I := 0 to 1000000 do 188 List.Add(1); 189 StartTime := Now; 190 I := 0; 191 repeat 192 List.Delete(0); 193 Inc(I); 194 until (Now - StartTime) > OneSecond; 195 WriteLn('Delete: ' + IntToStr(I) + ' ops/sec'); 196 List.Clear; 197 198 for I := 0 to 1000000 do 199 List.Add(1); 200 StartTime := Now; 201 I := 0; 202 repeat 203 List.Move(300000, 700000); 204 Inc(I); 205 until (Now - StartTime) > OneSecond; 206 WriteLn('Move: ' + IntToStr(I) + ' ops/sec'); 207 List.Clear; 208 209 finally 210 List.Free; 211 end; 212 213 try 214 List2 := TList.Create; 215 WriteLn('Test TList...'); 216 StartTime := Now; 217 repeat 218 List2.Add(1); 219 until (Now - StartTime) > OneSecond; 220 WriteLn('Add: ' + IntToStr(List2.Count) + ' ops/sec'); 221 List2.Clear; 222 223 StartTime := Now; 224 repeat 225 List2.Insert(0, 1); 226 until (Now - StartTime) > OneSecond; 227 WriteLn('Insert: ' + IntToStr(List2.Count) + ' ops/sec'); 228 List2.Clear; 229 230 for I := 0 to 1000000 do 231 List2.Add(1); 232 StartTime := Now; 233 I := 0; 234 repeat 235 List2.Delete(0); 236 Inc(I); 237 until (Now - StartTime) > OneSecond; 238 WriteLn('Delete: ' + IntToStr(I) + ' ops/sec'); 239 240 for I := 0 to 1000000 do 241 List2.Add(1); 242 StartTime := Now; 243 I := 0; 244 repeat 245 List2.Move(300000, 700000); 246 Inc(I); 247 until (Now - StartTime) > OneSecond; 248 WriteLn('Move: ' + IntToStr(I) + ' ops/sec'); 249 250 finally 251 List2.Free; 252 end; 253 end; 254 160 255 function StrToStr(Value: string): string; 161 256 begin
Note:
See TracChangeset
for help on using the changeset viewer.