665 test.Printf(_L(" variance == %f\n"), variance); |
665 test.Printf(_L(" variance == %f\n"), variance); |
666 |
666 |
667 delete [] data; |
667 delete [] data; |
668 } |
668 } |
669 |
669 |
670 void BenchmarkReplacement() |
670 void TestDistributions() |
671 { |
671 { |
672 test.Next(_L("Test uniform distribution")); |
672 test.Next(_L("Test uniform distribution")); |
673 TUniformRandom rand1; |
673 TUniformRandom rand1; |
674 rand1.SetParams(100); |
674 rand1.SetParams(100); |
675 TestDistribution(rand1, 10000); |
675 TestDistribution(rand1, 10000); |
676 |
676 |
677 test.Next(_L("Test normal distribution")); |
677 test.Next(_L("Test normal distribution")); |
678 TNormalRandom rand2; |
678 TNormalRandom rand2; |
679 rand2.SetParams(100, 25); |
679 rand2.SetParams(100, 25); |
680 TestDistribution(rand2, 10000); |
680 TestDistribution(rand2, 10000); |
|
681 } |
|
682 |
|
683 void BenchmarkReplacement() |
|
684 { |
|
685 // Report block write and physical access settings |
|
686 test.Next(_L("Report media physical access and preferred write size settings")); |
|
687 TInt physAccessSupported = UserSvr::HalFunction(EHalGroupVM, EVMHalGetPhysicalAccessSupported, 0, 0); |
|
688 test(physAccessSupported == 0 || physAccessSupported == 1); |
|
689 if (physAccessSupported) |
|
690 test.Printf(_L("Physical access supported\n")); |
|
691 else |
|
692 test.Printf(_L("Physical access not supported\n")); |
|
693 |
|
694 TInt preferredWriteSize = UserSvr::HalFunction(EHalGroupVM, EVMHalGetPreferredDataWriteSize, 0, 0); |
|
695 test(preferredWriteSize >= 0); |
|
696 test.Printf(_L("Preferred write size %d pages\n"), 1 << preferredWriteSize); |
|
697 |
|
698 for (TInt physAccess = 0 ; physAccess <= physAccessSupported ; ++physAccess) |
|
699 { |
|
700 test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalSetUsePhysicalAccess, (TAny*)physAccess, 0)); |
|
701 test_Equal(physAccess, UserSvr::HalFunction(EHalGroupVM, EVMHalGetUsePhysicalAccess, 0, 0)); |
|
702 TInt writeSize = 0; |
|
703 for (;;) |
|
704 { |
|
705 test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalSetDataWriteSize, (TAny*)writeSize, 0)); |
|
706 TInt writeSizeSet = UserSvr::HalFunction(EHalGroupVM, EVMHalGetDataWriteSize, 0, 0); |
|
707 test (writeSizeSet >= 0); |
|
708 if (writeSizeSet != writeSize) |
|
709 break; // stop loop when we reach limit of supported write size |
|
710 |
|
711 TBuf<128> title; |
|
712 title.AppendFormat(_L("Thrash test: single thread, normal random workload 2, phys access %d, write size %dKB"), |
|
713 physAccess, 1 << (writeSize - 2)); |
|
714 ThrashTest(title, 1, ETrue, EWorkloadNormalRandom2, (2 * gMaxCacheSize) / 3, 2 * gMaxCacheSize, 0); |
|
715 |
|
716 ++writeSize; |
|
717 } |
|
718 } |
|
719 |
|
720 test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalSetUsePhysicalAccess, (TAny*)physAccessSupported, 0)); |
|
721 test_Equal(physAccessSupported, UserSvr::HalFunction(EHalGroupVM, EVMHalGetUsePhysicalAccess, 0, 0)); |
|
722 test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalSetDataWriteSize, (TAny*)preferredWriteSize, 0)); |
|
723 test_Equal(preferredWriteSize, UserSvr::HalFunction(EHalGroupVM, EVMHalGetDataWriteSize, 0, 0)); |
681 |
724 |
682 ThrashTest(_L("Thrash test: single thread, normal random workload 1"), |
725 ThrashTest(_L("Thrash test: single thread, normal random workload 1"), |
683 1, ETrue, EWorkloadNormalRandom1, (2 * gMaxCacheSize) / 3, 2 * gMaxCacheSize, 0); |
726 1, ETrue, EWorkloadNormalRandom1, (2 * gMaxCacheSize) / 3, 2 * gMaxCacheSize, 0); |
684 |
727 |
685 ThrashTest(_L("Thrash test: single thread, normal random workload 2"), |
728 ThrashTest(_L("Thrash test: single thread, normal random workload 2"), |