kerneltest/e32test/demandpaging/t_thrash.cpp
changeset 201 43365a9b78a3
parent 90 947f0dc9f7a8
equal deleted inserted replaced
200:73ea206103e6 201:43365a9b78a3
   268 	do
   268 	do
   269 		{	
   269 		{	
   270 		RThread thread;
   270 		RThread thread;
   271 		test_KErrNone(thread.Create(_L("EnsureSystemIdleThread"), EnsureSystemIdleThread, 1024, NULL, NULL));		
   271 		test_KErrNone(thread.Create(_L("EnsureSystemIdleThread"), EnsureSystemIdleThread, 1024, NULL, NULL));		
   272 		thread.SetPriority(EPriorityLess);
   272 		thread.SetPriority(EPriorityLess);
   273 		thread.Resume();
       
   274 
       
   275 		TRequestStatus status;
   273 		TRequestStatus status;
   276 		thread.Rendezvous(status);
   274 		thread.Rendezvous(status);
       
   275 		thread.Resume();
       
   276 
   277 		User::WaitForRequest(status);
   277 		User::WaitForRequest(status);
   278 		test_KErrNone(status.Int());
   278 		test_KErrNone(status.Int());
   279 
   279 
   280 		User::After(KSampleTime);
   280 		User::After(KSampleTime);
   281 		thread.Suspend();
   281 		thread.Suspend();
   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"),
   851 		}
   894 		}
   852 	
   895 	
   853 	if (actions & EActionBenchmarks)
   896 	if (actions & EActionBenchmarks)
   854 		{	
   897 		{	
   855 		test.Next(_L("Benchmarking page replacement"));
   898 		test.Next(_L("Benchmarking page replacement"));
       
   899 		TestDistributions();
   856 		BenchmarkReplacement();
   900 		BenchmarkReplacement();
   857 		}
   901 		}
   858 
   902 
   859 	if (gDataPagingSupported)
   903 	if (gDataPagingSupported)
   860 		{
   904 		{