Changeset 110 for Generics/TemplateGenerics/Demo/UMainForm.pas
- Timestamp:
- Jan 3, 2011, 7:30:09 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Demo/UMainForm.pas
r109 r110 39 39 private 40 40 public 41 MeasureDuration: TDateTime; 41 42 Bitmap: TBitmap; 43 procedure UpdateButtonState(Enabled: Boolean); 42 44 procedure WriteOutput(Text1: string = ''; Text2: string = ''); 43 45 end; … … 54 56 procedure TMainForm.FormCreate(Sender: TObject); 55 57 begin 58 MeasureDuration := 100 * OneMillisecond; 56 59 end; 57 60 … … 236 239 ListViewOutput.Clear; 237 240 try 241 UpdateButtonState(False); 238 242 List := TListPointer.Create; 239 243 List2 := TList.Create; … … 242 246 repeat 243 247 List.Add(1); 244 until (Now - StartTime) > OneSecond;248 until (Now - StartTime) > MeasureDuration; 245 249 WriteOutput('TListPointer.Add', IntToStr(List.Count) + ' ops/sec'); 246 250 List.Clear; … … 250 254 repeat 251 255 List2.Add(1); 252 until (Now - StartTime) > OneSecond;256 until (Now - StartTime) > MeasureDuration; 253 257 WriteOutput('TList.Add', IntToStr(List2.Count) + ' ops/sec'); 254 258 List2.Clear; … … 258 262 repeat 259 263 List.Insert(0, 1); 260 until (Now - StartTime) > OneSecond;264 until (Now - StartTime) > MeasureDuration; 261 265 WriteOutput('TListPointer.Insert', IntToStr(List.Count) + ' ops/sec'); 262 266 List.Clear; … … 266 270 repeat 267 271 List2.Insert(0, 1); 268 until (Now - StartTime) > OneSecond;272 until (Now - StartTime) > MeasureDuration; 269 273 WriteOutput('TList.Insert', IntToStr(List2.Count) + ' ops/sec'); 270 274 List2.Clear; … … 278 282 List.Delete(0); 279 283 Inc(I); 280 until (Now - StartTime) > OneSecond;284 until (Now - StartTime) > MeasureDuration; 281 285 WriteOutput('TListPointer.Delete', IntToStr(I) + ' ops/sec'); 282 286 List.Clear; … … 290 294 List2.Delete(0); 291 295 Inc(I); 292 until (Now - StartTime) > OneSecond;296 until (Now - StartTime) > MeasureDuration; 293 297 WriteOutput('TList.Delete', IntToStr(I) + ' ops/sec'); 294 298 Application.ProcessMessages; … … 301 305 List.Move(300000, 700000); 302 306 Inc(I); 303 until (Now - StartTime) > OneSecond;307 until (Now - StartTime) > MeasureDuration; 304 308 WriteOutput('TListPointer.Move', IntToStr(I) + ' ops/sec'); 305 309 List.Clear; … … 313 317 List2.Move(300000, 700000); 314 318 Inc(I); 315 until (Now - StartTime) > OneSecond;319 until (Now - StartTime) > MeasureDuration; 316 320 WriteOutput('TList.Move', IntToStr(I) + ' ops/sec'); 317 321 Application.ProcessMessages; … … 324 328 List.Exchange(300000, 700000); 325 329 Inc(I); 326 until (Now - StartTime) > OneSecond;330 until (Now - StartTime) > MeasureDuration; 327 331 WriteOutput('TListPointer.Exchange', IntToStr(I) + ' ops/sec'); 328 332 List.Clear; … … 336 340 List2.Exchange(300000, 700000); 337 341 Inc(I); 338 until (Now - StartTime) > OneSecond;342 until (Now - StartTime) > MeasureDuration; 339 343 WriteOutput('TList.Exchange', IntToStr(I) + ' ops/sec'); 340 344 Application.ProcessMessages; … … 347 351 List.IndexOf(Pointer(I mod List.Count)); 348 352 Inc(I); 349 until (Now - StartTime) > OneSecond;353 until (Now - StartTime) > MeasureDuration; 350 354 WriteOutput('TListPointer.IndexOf', IntToStr(I) + ' ops/sec'); 351 355 List.Clear; … … 359 363 List2.IndexOf(Pointer(I mod List2.Count)); 360 364 Inc(I); 361 until (Now - StartTime) > OneSecond;365 until (Now - StartTime) > MeasureDuration; 362 366 WriteOutput('TList.IndexOf', IntToStr(I) + ' ops/sec'); 363 367 Application.ProcessMessages; 364 368 365 369 finally 370 UpdateButtonState(True); 366 371 List.Free; 367 372 List2.Free; … … 380 385 ListViewOutput.Clear; 381 386 try 387 UpdateButtonState(False); 382 388 Dictionary := TDictionaryStringString.Create; 383 389 Dictionary2 := TStringList.Create; … … 389 395 Dictionary.Add(IntToStr(I), IntToStr(I)); 390 396 I := I + 1; 391 until (Now - StartTime) > OneSecond;397 until (Now - StartTime) > MeasureDuration; 392 398 WriteOutput('TDictionaryStringString.Add', IntToStr(Dictionary.Count) + ' ops/sec'); 393 399 Application.ProcessMessages; … … 398 404 Dictionary2.Add(IntToStr(I) + Dictionary2.NameValueSeparator + IntToStr(I)); 399 405 I := I + 1; 400 until (Now - StartTime) > OneSecond;406 until (Now - StartTime) > MeasureDuration; 401 407 WriteOutput('TStringList.Add', IntToStr(Dictionary2.Count) + ' ops/sec'); 402 408 Application.ProcessMessages; … … 407 413 R := Dictionary.Values[IntToStr(I mod Dictionary.Count)]; 408 414 I := I + 1; 409 until (Now - StartTime) > OneSecond;415 until (Now - StartTime) > MeasureDuration; 410 416 WriteOutput('TDictionaryStringString.Values', IntToStr(I) + ' ops/sec'); 411 417 Application.ProcessMessages; … … 416 422 R := Dictionary2.Values[IntToStr(I mod Dictionary2.Count)]; 417 423 I := I + 1; 418 until (Now - StartTime) > OneSecond;424 until (Now - StartTime) > MeasureDuration; 419 425 WriteOutput('TStringList.Values', IntToStr(I) + ' ops/sec'); 420 426 Application.ProcessMessages; … … 425 431 R := Dictionary.Keys[I mod Dictionary.Count]; 426 432 I := I + 1; 427 until (Now - StartTime) > OneSecond;433 until (Now - StartTime) > MeasureDuration; 428 434 WriteOutput('TDictionaryStringString.Keys', IntToStr(I) + ' ops/sec'); 429 435 Application.ProcessMessages; … … 434 440 R := Dictionary2.Names[I mod Dictionary2.Count]; 435 441 I := I + 1; 436 until (Now - StartTime) > OneSecond;442 until (Now - StartTime) > MeasureDuration; 437 443 WriteOutput('TStringList.Keys(Names)', IntToStr(I) + ' ops/sec'); 438 444 Application.ProcessMessages; … … 443 449 R := Dictionary.Items[I mod Dictionary.Count].Value; 444 450 I := I + 1; 445 until (Now - StartTime) > OneSecond;451 until (Now - StartTime) > MeasureDuration; 446 452 WriteOutput('TDictionaryStringString.Items', IntToStr(I) + ' ops/sec'); 447 453 Application.ProcessMessages; … … 452 458 R := Dictionary2.ValueFromIndex[I mod Dictionary2.Count]; 453 459 I := I + 1; 454 until (Now - StartTime) > OneSecond;460 until (Now - StartTime) > MeasureDuration; 455 461 WriteOutput('TStringList.Items(ValueFromIndex)', IntToStr(I) + ' ops/sec'); 456 462 Application.ProcessMessages; 457 463 458 464 finally 465 UpdateButtonState(True); 459 466 Dictionary.Free; 460 467 Dictionary2.Free; … … 494 501 end; 495 502 503 procedure TMainForm.UpdateButtonState(Enabled: Boolean); 504 begin 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; 514 end; 515 496 516 procedure TMainForm.WriteOutput(Text1: string = ''; Text2: string = ''); 497 517 var
Note:
See TracChangeset
for help on using the changeset viewer.