kerneltest/e32test/benchmark/property.cpp
changeset 148 31ea0f8e3c99
parent 0 a41df078684a
equal deleted inserted replaced
135:5e441a173c63 148:31ea0f8e3c99
   203 	{
   203 	{
   204 	}
   204 	}
   205 
   205 
   206 void Property::NotificationLatencyParent(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM)
   206 void Property::NotificationLatencyParent(TBMResult* aResult, TBMUInt64 aIter, struct Measurement* aM)
   207 	{
   207 	{
       
   208 	TRequestStatus st1, st2;
       
   209 
   208 	RProperty time;
   210 	RProperty time;
   209 	TInt r = time.Define(KPropBenchmarkCategory, 0, RProperty::EByteArray, KPassPolicy, KPassPolicy);
   211 	TInt r = time.Define(KPropBenchmarkCategory, 0, RProperty::EByteArray, KPassPolicy, KPassPolicy);
   210 	BM_ERROR(r, r == KErrNone);	
   212 	BM_ERROR(r, r == KErrNone);	
   211 	r = time.Attach(KPropBenchmarkCategory, 0);
   213 	r = time.Attach(KPropBenchmarkCategory, 0);
   212 	BM_ERROR(r, r == KErrNone);	
   214 	BM_ERROR(r, r == KErrNone);	
       
   215 	time.Subscribe(st2);
   213 
   216 
   214 	RProperty prop;	
   217 	RProperty prop;	
   215 	r = prop.Define(KPropBenchmarkCategory, 1, aM->iType, KPassPolicy, KPassPolicy);
   218 	r = prop.Define(KPropBenchmarkCategory, 1, aM->iType, KPassPolicy, KPassPolicy);
   216 	BM_ERROR(r, r == KErrNone);	
   219 	BM_ERROR(r, r == KErrNone);	
   217 	r = prop.Attach(KPropBenchmarkCategory, 1);
   220 	r = prop.Attach(KPropBenchmarkCategory, 1);
   218 	BM_ERROR(r, r == KErrNone);	
   221 	BM_ERROR(r, r == KErrNone);	
       
   222 	prop.Subscribe(st1);
       
   223 
       
   224 	RSemaphore sync;
       
   225 	r = sync.CreateGlobal(_L("sync"), 0);
       
   226 	BM_ERROR(r, r == KErrNone);	
   219 
   227 
   220 	NotificationLatencyArgs sl(aM->iType, aM->iSize, aM->iRemote, aIter, aM->iSetGetType);
   228 	NotificationLatencyArgs sl(aM->iType, aM->iSize, aM->iRemote, aIter, aM->iSetGetType);
   221 	MBMChild* child = property.SpawnChild(&sl);
   229 	MBMChild* child = property.SpawnChild(&sl);
       
   230 
   222 	for (TBMUInt64 i = 0; i < aIter; ++i)
   231 	for (TBMUInt64 i = 0; i < aIter; ++i)
   223 		{
   232 		{
   224 		TRequestStatus st;
   233 		sync.Signal();
   225 		prop.Subscribe(st);
   234 		User::WaitForRequest(st1);
   226 		User::WaitForRequest(st);
   235 		BM_ERROR(st1.Int(), st1.Int() == KErrNone);
       
   236 		prop.Subscribe(st1);
       
   237 
   227 		switch(aM->iSetGetType)
   238 		switch(aM->iSetGetType)
   228 			{
   239 			{
   229 		case EOneArg:
   240 		case EOneArg:
   230 			if (aM->iType == RProperty::EInt)
   241 			if (aM->iType == RProperty::EInt)
   231 				{
   242 				{
   256 			break;
   267 			break;
   257 			}
   268 			}
   258 
   269 
   259 		TBMTicks now;
   270 		TBMTicks now;
   260 		::bmTimer.Stamp(&now);
   271 		::bmTimer.Stamp(&now);
   261 		BM_ERROR(st.Int(), st.Int() == KErrNone);
   272 
   262 
   273 		User::WaitForRequest(st2);
   263 		// subscribe for the time just before Set()
   274 		BM_ERROR(st2.Int(), st2.Int() == KErrNone);
   264 		time.Subscribe(st);
   275 		time.Subscribe(st2);
   265 		User::WaitForRequest(st);
   276 
   266 		BM_ERROR(st.Int(), st.Int() == KErrNone);
       
   267 		// get the time just before Set()
   277 		// get the time just before Set()
   268 		TBMTicks propSetTime;
   278 		TBMTicks propSetTime;
   269 		TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime));
   279 		TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime));
   270 		r = time.Get(KPropBenchmarkCategory, 0, ptr);
   280 		r = time.Get(KPropBenchmarkCategory, 0, ptr);
   271 		BM_ERROR(r, r == KErrNone);	
   281 		BM_ERROR(r, r == KErrNone);	
   272 
   282 
   273 		aResult->Cumulate(TBMTicksDelta(propSetTime, now));
   283 		aResult->Cumulate(TBMTicksDelta(propSetTime, now));
   274 		}
   284 		}
       
   285 
       
   286 	prop.Cancel();
       
   287 	User::WaitForRequest(st1);
       
   288 	BM_ERROR(st1.Int(), st1.Int() == KErrCancel);
       
   289 	time.Cancel();
       
   290 	User::WaitForRequest(st2);
       
   291 	BM_ERROR(st2.Int(), st2.Int() == KErrCancel);
       
   292 
   275 	prop.Close();
   293 	prop.Close();
   276 	time.Close();
   294 	time.Close();
       
   295 	sync.Close();
   277 	child->WaitChildExit();
   296 	child->WaitChildExit();
       
   297 
   278 	r = prop.Delete(KPropBenchmarkCategory, 1);
   298 	r = prop.Delete(KPropBenchmarkCategory, 1);
   279 	BM_ERROR(r, r == KErrNone);	
   299 	BM_ERROR(r, r == KErrNone);	
   280 	r = time.Delete(KPropBenchmarkCategory, 0);
   300 	r = time.Delete(KPropBenchmarkCategory, 0);
   281 	BM_ERROR(r, r == KErrNone);	
   301 	BM_ERROR(r, r == KErrNone);	
   282 	}
   302 	}
   288 
   308 
   289 	for (TInt j = 0; j < RProperty::KMaxPropertySize; ++j)
   309 	for (TInt j = 0; j < RProperty::KMaxPropertySize; ++j)
   290 		{
   310 		{
   291 		iOutBuf[j] = (TUint8)(j + 1);
   311 		iOutBuf[j] = (TUint8)(j + 1);
   292 		}
   312 		}
       
   313 
   293 	RProperty time;
   314 	RProperty time;
       
   315 	TInt r = time.Attach(KPropBenchmarkCategory, 0);
       
   316 	BM_ERROR(r, r == KErrNone);	
       
   317 
   294 	RProperty prop;
   318 	RProperty prop;
   295 	TInt r = prop.Attach(KPropBenchmarkCategory, 1);
   319 	r = prop.Attach(KPropBenchmarkCategory, 1);
   296 	BM_ERROR(r, r == KErrNone);	
   320 	BM_ERROR(r, r == KErrNone);
       
   321 
       
   322 	RSemaphore sync;
       
   323 	r = sync.OpenGlobal(_L("sync"));
       
   324 	BM_ERROR(r, r == KErrNone);	
       
   325 
   297 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   326 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   298 		{
   327 		{
       
   328 		sync.Wait();
   299 		TBMTicks propSetTime;
   329 		TBMTicks propSetTime;
   300 		::bmTimer.Stamp(&propSetTime);
   330 		::bmTimer.Stamp(&propSetTime);
       
   331 
   301 		switch(sl->iSetGetType)
   332 		switch(sl->iSetGetType)
   302 			{
   333 			{
   303 		case EOneArg:
   334 		case EOneArg:
   304 			if (sl->iType == RProperty::EInt)
   335 			if (sl->iType == RProperty::EInt)
   305 				{
   336 				{
   334 			r = prop.Set(KPropBenchmarkCategory, 1, ptr);
   365 			r = prop.Set(KPropBenchmarkCategory, 1, ptr);
   335 			BM_ERROR(r, r == KErrNone);
   366 			BM_ERROR(r, r == KErrNone);
   336 			}
   367 			}
   337 			break;
   368 			break;
   338 			}
   369 			}
       
   370 
   339 		// publish the time just before Set()
   371 		// publish the time just before Set()
   340 		TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime));
   372 		TPtr8 ptr((TUint8*) &propSetTime, sizeof(propSetTime), sizeof(propSetTime));
   341 		r = time.Set(KPropBenchmarkCategory, 0, ptr);
   373 		r = time.Set(ptr);
   342 		BM_ERROR(r, r == KErrNone);
   374 		BM_ERROR(r, r == KErrNone);
   343 		}
   375 		}
       
   376 
   344 	prop.Close();
   377 	prop.Close();
   345 	time.Close();
   378 	time.Close();
       
   379 	sync.Close();
   346 
   380 
   347 	BMProgram::SetAbsPriority(RThread(), prio);
   381 	BMProgram::SetAbsPriority(RThread(), prio);
   348 	return KErrNone;
   382 	return KErrNone;
   349 	}
   383 	}
   350 
   384