kerneltest/e32test/benchmark/sync.cpp
changeset 149 d9f1e5bfe28c
parent 0 a41df078684a
equal deleted inserted replaced
135:5e441a173c63 149:d9f1e5bfe28c
   270 	iSignalTimeQue.Close();
   270 	iSignalTimeQue.Close();
   271 	}
   271 	}
   272 
   272 
   273 void Sync::SemaphoreLatencyParent(TBMResult* aResult, TBMUInt64 aIter, TBool aRemote)
   273 void Sync::SemaphoreLatencyParent(TBMResult* aResult, TBMUInt64 aIter, TBool aRemote)
   274 	{
   274 	{
       
   275 	RSemaphore slSync;
       
   276 	TInt r = slSync.CreateGlobal(_L("slSync"), 0);
       
   277 	BM_ERROR(r, r == KErrNone);	
       
   278 
   275 	SemaphoreLatencyArgs sl(aRemote, aIter);
   279 	SemaphoreLatencyArgs sl(aRemote, aIter);
   276 	MBMChild* child = sync.SpawnChild(&sl);
   280 	MBMChild* child = sync.SpawnChild(&sl);
   277 	for (TBMUInt64 i = 0; i < aIter; ++i)
   281 	for (TBMUInt64 i = 0; i < aIter; ++i)
   278 		{
   282 		{
       
   283 		slSync.Signal();
   279 		sl.iSem.Wait();
   284 		sl.iSem.Wait();
   280 		TBMTicks now;
   285 		TBMTicks now;
   281 		::bmTimer.Stamp(&now);
   286 		::bmTimer.Stamp(&now);
   282 		aResult->Cumulate(TBMTicksDelta(sl.SignalTime(), now));
   287 		aResult->Cumulate(TBMTicksDelta(sl.SignalTime(), now));
   283 		}
   288 		}
   284 	child->WaitChildExit();
   289 	child->WaitChildExit();
   285 	sl.Close();
   290 	sl.Close();
       
   291 	slSync.Close();
   286 	}
   292 	}
   287 
   293 
   288 TInt Sync::SemaphoreLatencyChild(TAny* ptr)
   294 TInt Sync::SemaphoreLatencyChild(TAny* ptr)
   289 	{
   295 	{
       
   296 	RSemaphore slSync;
       
   297 	TInt r = slSync.OpenGlobal(_L("slSync"));
       
   298 	BM_ERROR(r, r == KErrNone);	
       
   299 
   290 	SemaphoreLatencyArgs* sl = (SemaphoreLatencyArgs*) ptr;
   300 	SemaphoreLatencyArgs* sl = (SemaphoreLatencyArgs*) ptr;
   291 	sl->ChildOpen();
   301 	sl->ChildOpen();
   292 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   302 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   293 		{
   303 		{
       
   304 		slSync.Wait();
   294 		TBMTicks sigTime;
   305 		TBMTicks sigTime;
   295 		::bmTimer.Stamp(&sigTime);		
   306 		::bmTimer.Stamp(&sigTime);		
   296 		sl->iSem.Signal();
   307 		sl->iSem.Signal();
   297 		sl->ChildSignalTime(sigTime);
   308 		sl->ChildSignalTime(sigTime);
   298 		}
   309 		}
   299 	sl->ChildClose();
   310 	sl->ChildClose();
       
   311 	slSync.Close();
   300 	return KErrNone;
   312 	return KErrNone;
   301 	}
   313 	}
   302 
   314 
   303 class ThreadSemaphoreLatencyArgs : public TBMSpawnArgs
   315 class ThreadSemaphoreLatencyArgs : public TBMSpawnArgs
   304 	{
   316 	{
   366 	iSignalTimeQue.Close();
   378 	iSignalTimeQue.Close();
   367 	}
   379 	}
   368 
   380 
   369 void Sync::ThreadSemaphoreLatencyParent(TBMResult* aResult, TBMUInt64 aIter, TBool aRemote)
   381 void Sync::ThreadSemaphoreLatencyParent(TBMResult* aResult, TBMUInt64 aIter, TBool aRemote)
   370 	{
   382 	{
       
   383 	RSemaphore tslSync;
       
   384 	TInt r = tslSync.CreateGlobal(_L("tslSync"), 0);
       
   385 	BM_ERROR(r, r == KErrNone);	
       
   386 
   371 	ThreadSemaphoreLatencyArgs sl(aRemote, aIter);
   387 	ThreadSemaphoreLatencyArgs sl(aRemote, aIter);
   372 	MBMChild* child = sync.SpawnChild(&sl);
   388 	MBMChild* child = sync.SpawnChild(&sl);
   373 	for (TBMUInt64 i = 0; i < aIter; ++i)
   389 	for (TBMUInt64 i = 0; i < aIter; ++i)
   374 		{
   390 		{
   375 		sl.iStatus = KRequestPending;
   391 		sl.iStatus = KRequestPending;
       
   392 		tslSync.Signal();
   376 		User::WaitForRequest(sl.iStatus);
   393 		User::WaitForRequest(sl.iStatus);
   377 		BM_ASSERT(sl.iStatus == KErrNone);
   394 		BM_ASSERT(sl.iStatus == KErrNone);
   378 		TBMTicks now;
   395 		TBMTicks now;
   379 		::bmTimer.Stamp(&now);
   396 		::bmTimer.Stamp(&now);
   380 		aResult->Cumulate(TBMTicksDelta(sl.SignalTime(), now));
   397 		aResult->Cumulate(TBMTicksDelta(sl.SignalTime(), now));
   381 		}
   398 		}
   382 	child->WaitChildExit();
   399 	child->WaitChildExit();
   383 	sl.Close();
   400 	sl.Close();
       
   401 	tslSync.Close();
   384 	}
   402 	}
   385 
   403 
   386 TInt Sync::ThreadSemaphoreLatencyChild(TAny* ptr)
   404 TInt Sync::ThreadSemaphoreLatencyChild(TAny* ptr)
   387 	{
   405 	{
       
   406 	RSemaphore tslSync;
       
   407 	TInt r = tslSync.OpenGlobal(_L("tslSync"));
       
   408 	BM_ERROR(r, r == KErrNone);	
       
   409 
   388 	ThreadSemaphoreLatencyArgs* sl = (ThreadSemaphoreLatencyArgs*) ptr;
   410 	ThreadSemaphoreLatencyArgs* sl = (ThreadSemaphoreLatencyArgs*) ptr;
   389 	sl->ChildOpen();
   411 	sl->ChildOpen();
   390 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   412 	for (TBMUInt64 i = 0; i < sl->iIterationCount; ++i)
   391 		{
   413 		{
       
   414 		tslSync.Wait();
   392 		TRequestStatus* sptr = sl->iStatusPtr;
   415 		TRequestStatus* sptr = sl->iStatusPtr;
   393 		TBMTicks sigTime;
   416 		TBMTicks sigTime;
   394 		::bmTimer.Stamp(&sigTime);		
   417 		::bmTimer.Stamp(&sigTime);		
   395 		sl->iParent.RequestComplete(sptr, KErrNone);
   418 		sl->iParent.RequestComplete(sptr, KErrNone);
   396 		sl->ChildSignalTime(sigTime);
   419 		sl->ChildSignalTime(sigTime);
   397 		}
   420 		}
   398 	sl->ChildClose();
   421 	sl->ChildClose();
       
   422 	tslSync.Close();
   399 	return KErrNone;
   423 	return KErrNone;
   400 	}
   424 	}
   401 
   425 
   402 						
   426 						
   403 TBMResult* Sync::Run(TBMUInt64 aIter, TInt* aCount)
   427 TBMResult* Sync::Run(TBMUInt64 aIter, TInt* aCount)