Changeset 219 for Generics/TemplateGenerics/Demo/UMainForm.pas
- Timestamp:
- Mar 24, 2011, 6:50:50 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Generics/TemplateGenerics/Demo/UMainForm.pas
r111 r219 478 478 var 479 479 List: TListPointer; 480 List2: T List;480 List2: TFPList; 481 481 StartTime: TDateTime; 482 482 I: Integer; … … 484 484 SampleCount: Integer = 100000; 485 485 begin 486 LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic T List benchmark';486 LabelTestName.Caption := 'Generic specialized TListObject vs. classic non-generic TFPList benchmark'; 487 487 ListViewOutput.Clear; 488 488 try 489 489 UpdateButtonState(False); 490 490 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)); 496 499 until (Now - StartTime) > MeasureDuration; 497 500 WriteOutput('TListPointer.Add', IntToStr(List.Count) + ' ops'); … … 501 504 StartTime := Now; 502 505 repeat 503 List2.Add( 1);504 until (Now - StartTime) > MeasureDuration; 505 WriteOutput('T List.Add', IntToStr(List2.Count) + ' ops');506 List2.Add(Pointer(1)); 507 until (Now - StartTime) > MeasureDuration; 508 WriteOutput('TFPList.Add', IntToStr(List2.Count) + ' ops'); 506 509 List2.Clear; 507 510 Application.ProcessMessages; … … 509 512 StartTime := Now; 510 513 repeat 511 List.Insert(0, 1);514 List.Insert(0, Pointer(1)); 512 515 until (Now - StartTime) > MeasureDuration; 513 516 WriteOutput('TListPointer.Insert', IntToStr(List.Count) + ' ops'); … … 517 520 StartTime := Now; 518 521 repeat 519 List2.Insert(0, 1);520 until (Now - StartTime) > MeasureDuration; 521 WriteOutput('T List.Insert', IntToStr(List2.Count) + ' ops');522 List2.Insert(0, Pointer(1)); 523 until (Now - StartTime) > MeasureDuration; 524 WriteOutput('TFPList.Insert', IntToStr(List2.Count) + ' ops'); 522 525 List2.Clear; 523 526 Application.ProcessMessages; 524 527 525 528 for I := 0 to SampleCount - 1 do 526 List.Add( 1);529 List.Add(Pointer(1)); 527 530 StartTime := Now; 528 531 I := 0; … … 536 539 537 540 for I := 0 to SampleCount - 1 do 538 List2.Add( 1);541 List2.Add(Pointer(1)); 539 542 StartTime := Now; 540 543 I := 0; … … 543 546 Inc(I); 544 547 until (Now - StartTime) > MeasureDuration; 545 WriteOutput('T List.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)); 550 553 StartTime := Now; 551 554 I := 0; … … 559 562 560 563 for I := 0 to SampleCount - 1 do 561 List2.Add( 1);564 List2.Add(Pointer(1)); 562 565 StartTime := Now; 563 566 I := 0; … … 566 569 Inc(I); 567 570 until (Now - StartTime) > MeasureDuration; 568 WriteOutput('T List.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)); 573 576 StartTime := Now; 574 577 I := 0; … … 582 585 583 586 for I := 0 to SampleCount - 1 do 584 List2.Add( 1);587 List2.Add(Pointer(1)); 585 588 StartTime := Now; 586 589 I := 0; … … 589 592 Inc(I); 590 593 until (Now - StartTime) > MeasureDuration; 591 WriteOutput('T List.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)); 596 599 StartTime := Now; 597 600 I := 0; … … 605 608 606 609 for I := 0 to SampleCount - 1 do 607 List2.Add( 1);610 List2.Add(Pointer(1)); 608 611 StartTime := Now; 609 612 I := 0; … … 612 615 Inc(I); 613 616 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; 617 665 finally 618 666 UpdateButtonState(True);
Note:
See TracChangeset
for help on using the changeset viewer.