kerneltest/e32test/misc/cpumeter.cpp
branchRCL_3
changeset 256 c1f20ce4abcf
parent 0 a41df078684a
child 257 3e88ff8f41d5
equal deleted inserted replaced
249:a179b74831c9 256:c1f20ce4abcf
    46 	~CCpuMeter();
    46 	~CCpuMeter();
    47 	static CCpuMeter* New();
    47 	static CCpuMeter* New();
    48 	TInt Construct();
    48 	TInt Construct();
    49 	void Measure();
    49 	void Measure();
    50 	void Display(TInt aInterval);
    50 	void Display(TInt aInterval);
       
    51 	void DisplayCoreControlInfo();
       
    52 	void ChangeNumberOfCores(TInt aNum);
    51 public:
    53 public:
    52 	TInt iNumCpus;
    54 	TInt iNumCpus;
    53 	TInt iNextMeas;
    55 	TInt iNextMeas;
    54 	RThread* iNullThreads;
    56 	RThread* iNullThreads;
    55 	TTimeIntervalMicroSeconds* iMeas[2];
    57 	TTimeIntervalMicroSeconds* iMeas[2];
   150 		}
   152 		}
   151 	buf.Append(TChar('\n'));
   153 	buf.Append(TChar('\n'));
   152 	test.Printf(buf);
   154 	test.Printf(buf);
   153 	}
   155 	}
   154 
   156 
       
   157 void CCpuMeter::DisplayCoreControlInfo()
       
   158 	{
       
   159 	SCpuStates s;
       
   160 	TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalCpuStates, &s, 0);
       
   161 	if (r != KErrNone)
       
   162 		{
       
   163 		test.Printf(_L("Error %d\n"), r);
       
   164 		return;
       
   165 		}
       
   166 	test.SetLogged(ETrue);
       
   167 	test.Printf(_L("  TA=%08x IA=%08x CU=%08x GD=%08x DC=%08x\n"), s.iTA, s.iIA, s.iCU, s.iGD, s.iDC);
       
   168 	test.Printf(_L("  SC=%08x RC=%08x PO=%02x      CCS=%08x PODC=%08x\n"), s.iSC, s.iRC, s.iPO, s.iCCS, s.iPODC);
       
   169 	TInt i;
       
   170 	for (i=0; i<iNumCpus; ++i)
       
   171 		{
       
   172 		test.Printf(_L("%1d:DS=%08x UDC=%08x UAC=%08x OP=%08x F=%08x\n"), i, s.iDS[i], s.iUDC[i], s.iUAC[i], s.iOP[i], s.iF[i]);
       
   173 		}
       
   174 	test.SetLogged(EFalse);
       
   175 	}
       
   176 
       
   177 void CCpuMeter::ChangeNumberOfCores(TInt aNum)
       
   178 	{
       
   179 	test.SetLogged(ETrue);
       
   180 	test.Printf(_L("#CORES->%d\n"), aNum);
       
   181 	TInt r = UserSvr::HalFunction(EHalGroupKernel, EKernelHalSetNumberOfCpus, (TAny*)aNum, 0);
       
   182 	if (r != KErrNone)
       
   183 		{
       
   184 		test.Printf(_L("Error %d\n"), r);
       
   185 		}
       
   186 	test.SetLogged(EFalse);
       
   187 	}
       
   188 
   155 void UseKernelCpuTime()
   189 void UseKernelCpuTime()
   156 	{
   190 	{
   157 	test.Start(_L("Create CCpuMeter"));
   191 	test.Start(_L("Create CCpuMeter"));
   158 	CCpuMeter* m = CCpuMeter::New();
   192 	CCpuMeter* m = CCpuMeter::New();
   159 	test_NotNull(m);
   193 	test_NotNull(m);
   172 			TKeyCode k = console->KeyCode();
   206 			TKeyCode k = console->KeyCode();
   173 			if (k == EKeyEscape)
   207 			if (k == EKeyEscape)
   174 				{
   208 				{
   175 				delete m;
   209 				delete m;
   176 				return;
   210 				return;
       
   211 				}
       
   212 			if (m->iNumCpus > 1)
       
   213 				{
       
   214 				// SMP only options
       
   215 				if (k == EKeySpace)
       
   216 					m->DisplayCoreControlInfo();
       
   217 				else if (k>='1' && k<=('0'+m->iNumCpus))
       
   218 					m->ChangeNumberOfCores(k - '0');
   177 				}
   219 				}
   178 			console->Read(s);
   220 			console->Read(s);
   179 			}
   221 			}
   180 		}
   222 		}
   181 	}
   223 	}