kerneltest/e32test/benchmark/bm_main.cpp
branchRCL_3
changeset 39 2bb754abd467
parent 0 a41df078684a
equal deleted inserted replaced
36:bbf8bed59bcb 39:2bb754abd467
    76 
    76 
    77 #include "bm_suite.h"
    77 #include "bm_suite.h"
    78 #include <e32svr.h>
    78 #include <e32svr.h>
    79 #include <u32hal.h>
    79 #include <u32hal.h>
    80 
    80 
    81 RTest test(_L("Benchmark Suite"));
       
    82 
       
    83 //
    81 //
    84 // The default value of the time allocated for one benchmark program.  
    82 // The default value of the time allocated for one benchmark program.  
    85 //
    83 //
    86 static TInt KBMSecondsPerProgram = 30;
    84 static TInt KBMSecondsPerProgram = 30;
    87 //
    85 //
   298 void CLocalChild::WaitChildExit()
   296 void CLocalChild::WaitChildExit()
   299 	{
   297 	{
   300 	User::WaitForRequest(iExitStatus);
   298 	User::WaitForRequest(iExitStatus);
   301 	CLOSE_AND_WAIT(iChild);
   299 	CLOSE_AND_WAIT(iChild);
   302 	//
   300 	//
   303 	// Lower the parent thread prioirty and then restore the current one 
   301 	// Lower the parent thread priority and then restore the current one 
   304 	// to make sure that the kernel-side thread destruction DFC had a chance to complete.
   302 	// to make sure that the kernel-side thread destruction DFC had a chance to complete.
   305 	//
   303 	//
   306 	TInt prio = BMProgram::SetAbsPriority(RThread(), iProg->iOrigAbsPriority);
   304 	TInt prio = BMProgram::SetAbsPriority(RThread(), iProg->iOrigAbsPriority);
   307 	BMProgram::SetAbsPriority(RThread(), prio);
   305 	BMProgram::SetAbsPriority(RThread(), prio);
   308 	delete this;
   306 	delete this;
   360 void CRemoteChild::WaitChildExit()
   358 void CRemoteChild::WaitChildExit()
   361 	{
   359 	{
   362 	User::WaitForRequest(iExitStatus);
   360 	User::WaitForRequest(iExitStatus);
   363 	CLOSE_AND_WAIT(iChild);
   361 	CLOSE_AND_WAIT(iChild);
   364 	//
   362 	//
   365 	// Lower the parent thread prioirty and then restore the current one 
   363 	// Lower the parent thread priority and then restore the current one 
   366 	// to make sure that the kernel-side thread destruction DFC had a chance to complete.
   364 	// to make sure that the kernel-side thread destruction DFC had a chance to complete.
   367 	//
   365 	//
   368 	TInt prio = BMProgram::SetAbsPriority(RThread(), iProg->iOrigAbsPriority);
   366 	TInt prio = BMProgram::SetAbsPriority(RThread(), iProg->iOrigAbsPriority);
   369 	BMProgram::SetAbsPriority(RThread(), prio);
   367 	BMProgram::SetAbsPriority(RThread(), prio);
   370 	delete this;
   368 	delete this;
   416 //
   414 //
   417 // The benchmark-suite entry point.
   415 // The benchmark-suite entry point.
   418 //
   416 //
   419 GLDEF_C TInt E32Main()
   417 GLDEF_C TInt E32Main()
   420 	{
   418 	{
       
   419 	RTest test(_L("Benchmark Suite"));
   421 	test.Title();
   420 	test.Title();
   422 
   421 
   423 	TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalNumLogicalCpus, 0, 0);
       
   424 	if (r != 1)
       
   425 		{
       
   426 		test.Printf(_L("%d CPUs detected ... test not run\n"), r);
       
   427 		return r;
       
   428 		}
       
   429 	
       
   430 	AddProperty();
   422 	AddProperty();
   431 	AddThread();
   423 	AddThread();
   432 	AddIpc();
   424 	AddIpc();
   433 	AddSync();
   425 	AddSync();
   434 	AddOverhead();
   426 	AddOverhead();
   435 	AddrtLatency();
   427 	AddrtLatency();
   436 
   428 
   437 	r = User::LoadPhysicalDevice(KBMPddFileName);
   429 	TInt r = User::LoadPhysicalDevice(KBMPddFileName);
   438 	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));
   430 	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));
   439 
   431 
   440 	r = User::LoadLogicalDevice(KBMLddFileName);
   432 	r = User::LoadLogicalDevice(KBMLddFileName);
   441 	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));
   433 	BM_ERROR(r, (r == KErrNone) || (r == KErrAlreadyExists));
   442 
   434 
   543 		//
   535 		//
   544 		// Now the real run ...
   536 		// Now the real run ...
   545 		//
   537 		//
   546 		TBMResult* results = prog->Run(iter, &count);
   538 		TBMResult* results = prog->Run(iter, &count);
   547 
   539 
   548 			// Restore the original prioirty
   540 			// Restore the original priority
   549 		BMProgram::SetAbsPriority(RThread(), prog->iOrigAbsPriority);
   541 		BMProgram::SetAbsPriority(RThread(), prog->iOrigAbsPriority);
   550 
   542 
   551 		//
   543 		//
   552 		// Now print out the results
   544 		// Now print out the results
   553 		//
   545 		//
   615 	}
   607 	}
   616 
   608 
   617 
   609 
   618 void bm_assert_failed(char* aCond, char* aFile, TInt aLine)
   610 void bm_assert_failed(char* aCond, char* aFile, TInt aLine)
   619 	{
   611 	{
       
   612 	RTest test(_L("Benchmark Suite Assert Failed"));
       
   613 	test.Title();
       
   614 
   620 	TPtrC8 fd((TUint8*)aFile);
   615 	TPtrC8 fd((TUint8*)aFile);
   621 	TPtrC8 cd((TUint8*)aCond);
   616 	TPtrC8 cd((TUint8*)aCond);
   622 
   617 
   623 	HBufC* fhb = HBufC::NewMax(fd.Length());
   618 	HBufC* fhb = HBufC::NewMax(fd.Length());
   624 	test(fhb != 0);
   619 	test(fhb != 0);
   632 	test(0);
   627 	test(0);
   633 	}
   628 	}
   634 
   629 
   635 void bm_error_detected(TInt aError, char* aCond, char* aFile, TInt aLine)
   630 void bm_error_detected(TInt aError, char* aCond, char* aFile, TInt aLine)
   636 	{
   631 	{
       
   632 	RTest test(_L("Benchmark Suite Error Detected"));
       
   633 	test.Title();
       
   634 
   637 	TPtrC8 fd((TUint8*)aFile);
   635 	TPtrC8 fd((TUint8*)aFile);
   638 	TPtrC8 cd((TUint8*)aCond);
   636 	TPtrC8 cd((TUint8*)aCond);
   639 
   637 
   640 	HBufC* fhb = HBufC::NewMax(fd.Length());
   638 	HBufC* fhb = HBufC::NewMax(fd.Length());
   641 	test(fhb != 0);
   639 	test(fhb != 0);