Example #1
0
   virtual dword GetPlayPos() const{

      if(!inited)
         return 0;
      if(finished)
         return GetPlayTime();
      dword ret;
#ifdef USE_OPTIONAL_POSITIONING
      const_cast<C_simple_sound_player_imp*>(this)->InitLib();
      if(mca_GetPosition){
         TTimeIntervalMicroSeconds p;
#ifdef _DEBUG
         (plr->*mca_GetPosition)(p);
#else
         mca_GetPosition(plr, p);
#endif
         ret = (p.Int64()/TInt64(1000)).Low();
      }else
         ret = 0;
#else
      TTimeIntervalMicroSeconds p;
      plr->GetPosition(p);
      ret = dword(p.Int64()/TInt64(1000));
#endif
      return Min(ret, GetPlayTime());
   }
void CTzBootPerformanceTest::TestBootupPerformanceL()
	{
	TTime startTime;
	TTime endTime;
	startTime.UniversalTime();

	RTz tz;
	User::LeaveIfError(tz.Connect());
	endTime.UniversalTime();
	tz.Close();
	
	TTimeIntervalMicroSeconds micros = endTime.MicroSecondsFrom(startTime);
	_LIT(KBootTime, "Time to connect time zone server = %d (ms) \n");
	test.Printf(KBootTime,micros);
	
#ifndef __WINS__
	
#ifdef GetPerformanceBaseline
	bootTimeBaseLine = micros.Int64();
	_LIT(KBootTimeBaseLine, "The baseline of boot-up time = %d (ms) \n");
	test.Printf(KBootTimeBaseLine,bootTimeBaseLine);
#else
	test((micros.Int64()-bootTimeBaseLine)/bootTimeBaseLine<0.1);
#endif
	
#endif
	}
void CCopyContactsAO::UpdateTimeStamp()
{
	RFs fs;
	fs.Connect();

	TBuf<256> cdbFileName; // Contact db file name

	if (iDatabase->FindContactFile(cdbFileName)) {

		TTime cdbTime;
		fs.Modified(cdbFileName, cdbTime);

		TDateTime janNineteenSeventy
				(1970,EJanuary,0,00,00,00,000000);
		TTime timejan(janNineteenSeventy);

		TTimeIntervalMicroSeconds interval =
				cdbTime.MicroSecondsFrom(timejan);

		TInt64 cdbVal;
		cdbVal = interval.Int64()/1000;

		TBuf<256> timestamp;
		timestamp.Num(cdbVal);

		iAppUi.AddTimeStampToFileL(&timestamp);
	}

	fs.Close();
}
// ---------------------------------------------------------------------------
// Configures the flex window sizes for both the initial delay and the
// consequent intervals after that. 64-bit version.
// ---------------------------------------------------------------------------
//
EXPORT_C TInt CFlexPeriodic::Configure( 
                                   TTimeIntervalMicroSeconds aDelayWindow,
                                   TTimeIntervalMicroSeconds aIntervalWindow )
    {
    OstTraceExt3( TRACE_NORMAL, DUP1_CFLEXPERIODIC_CONFIGURE,
            "CFlexPeriodic::Configure64;this=%x;"
            "aDelayWindow=%lld;aIntervalWindow=%lld", ( TUint )this,
            aDelayWindow.Int64(), aIntervalWindow.Int64() );

    TTimeIntervalMicroSeconds zero( 0 );
    __ASSERT_ALWAYS(aDelayWindow >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicDelayWindowLessThanZero));
    __ASSERT_ALWAYS(aIntervalWindow >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicIntervalWindowLessThanZero));

    // interval window is saved for later use. Delay window is sent
    // immediately to server. 
    TInt ret = CFlexTimer::Configure( aDelayWindow );
    if ( ret == KErrNone )
        {
        // Interval window is changed only, if configuration is successful.
        iIntervalWindow = aIntervalWindow;
        
        // This is set to true only, if the server is able to receive the
        // delay window configuration.
        iSendConfigure = ETrue;
        }
    return ret;
    }
// ---------------------------------------------------------------------------
// Starts the periodic timer. 64-bit delay and interval parameters.
// ---------------------------------------------------------------------------
//
EXPORT_C void CFlexPeriodic::Start( TTimeIntervalMicroSeconds aDelay,
                                    TTimeIntervalMicroSeconds anInterval,
                                    TCallBack aCallBack,
                                    TCallBack aCallBackError )
    {
    OstTraceExt4( TRACE_NORMAL, CFLEXPERIODIC_START64,
            "CFlexPeriodic::Start64;this=%x;aDelay=%lld;"
            "anInterval=%lld;aCallBack=%x", ( TUint )this,
            aDelay.Int64(), anInterval.Int64(), ( TUint )&( aCallBack ) );

    TTimeIntervalMicroSeconds zero( 0 );
    __ASSERT_ALWAYS(aDelay >= zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicDelayLessThanZero));
    __ASSERT_ALWAYS(anInterval > zero,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicIntervalTooSmall));
    __ASSERT_ALWAYS( aCallBack.iFunction != NULL,
            User::Panic(KCFlexPeriodicPanicCat,
                    EFlexPeriodicCallbackFunctionIsNull));
    // aCallBackError is left unasserted on purpose.
    // if error occurs and callback is null client is paniced.
    
    // Interval value is saved for later use, delay is sent immediately
    // to the server.
    iInterval = anInterval.Int64();
    iCallBack = aCallBack;
    iCallBackError = aCallBackError;
    CFlexTimer::After( aDelay );
    }
EXPORT_C TBool TWsGraphicMsgAnimation::IsPlaying(const TTime& aNow,const TTimeIntervalMicroSeconds& aAnimationLength) const
	{
	// an animation to time?
	if(aAnimationLength <= 0LL)
		{
		return EFalse;
		}
	switch(iFlags & EStateMask)
		{
		case EPaused:
			return EFalse;
		case EStopping:
			{
			const TInt64 elapsed = (aNow.Int64() - iPlay.Int64());
			if(elapsed <= aAnimationLength.Int64())
				{
				return ETrue;
				}
			return EFalse;
			}
		case EStopped:
			return EFalse;
		case EPlaying:
			{
			const TInt64 elapsed = (aNow.Int64() - iPlay.Int64());
			if((iFlags & ELoop) || (elapsed <= aAnimationLength.Int64()))
				{
				return ETrue;
				}
			return EFalse;
			}
		default:
			return EFalse;
		}
	}
void UT_CG711PayloadFormatWrite::UT_CG711PayloadFormatWrite_FrameTimeIntervalL(  )
{
    //iWrite->iFrameTimeInterval = 20000 *  2;  // 20k * Channels
    TTimeIntervalMicroSeconds catchAfish;
    TMediaId mediaIdAudio( KUidMediaTypeAudio, 1 );
    TMediaId mediaIdVideo( KUidMediaTypeVideo, 1 );

    if ( !iAlloc )
    {
        catchAfish = iWrite->FrameTimeInterval ( mediaIdAudio );
        EUNIT_ASSERT_EQUALS( catchAfish.Int64(), 0 );

        catchAfish = iWrite->FrameTimeInterval ( mediaIdVideo );
        EUNIT_ASSERT_EQUALS( catchAfish.Int64(), 0 );


    }

    else
    {
        EUNIT_ASSERT_NO_LEAVE( iWrite->FrameTimeInterval ( mediaIdAudio ) );
        EUNIT_ASSERT_NO_LEAVE( iWrite->FrameTimeInterval ( mediaIdVideo ) );

    }
}
Example #8
0
/*CPU and Memory Usage*/
GF_EXPORT
Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags)
{
	TInt ram, ram_free;
	u32 now, time;
#ifdef __SERIES60_3X__
	TModuleMemoryInfo mi;
#endif
	TTimeIntervalMicroSeconds tims;
	RProcess cur_process;
	RThread cur_th;

	now = gf_sys_clock();
	if (!rti->sampling_instant) {
		rti->sampling_instant = now;
		if (cur_th.GetCpuTime(tims) != KErrNone) {
			return 0;
		}
#ifdef __SERIES60_3X__
		rti->process_cpu_time = (u32) (tims.Int64() / 1000);
#else
		rti->process_cpu_time = (u32) ( TInt64(tims.Int64() / 1000).GetTInt() );
#endif
		return 0;
	}
	if (rti->sampling_instant + refresh_time_ms > now) return 0;
	rti->sampling_period_duration = now - rti->sampling_instant;
	rti->sampling_instant = now;

	if (cur_th.Process(cur_process) != KErrNone) {
		return 0;
	}
#ifdef __SERIES60_3X__
	if (cur_process.GetMemoryInfo(mi) != KErrNone) {
		return 0;
	}
	rti->process_memory = mi.iCodeSize + mi.iConstDataSize + mi.iInitialisedDataSize + mi.iUninitialisedDataSize;
#endif
	if (cur_th.GetCpuTime(tims) != KErrNone) {
		return 0;
	}
#ifdef __SERIES60_3X__
	time = (u32) (tims.Int64() / 1000);
#else
	time = (u32) ( TInt64(tims.Int64() / 1000).GetTInt() );
#endif
	rti->process_cpu_time_diff = time - rti->process_cpu_time;
	rti->process_cpu_time = time;
	rti->process_cpu_usage = 100*rti->process_cpu_time_diff / rti->sampling_period_duration;
	if (rti->process_cpu_usage > 100) rti->process_cpu_usage = 100;

	HAL::Get(HALData::EMemoryRAM, ram);
	HAL::Get(HALData::EMemoryRAMFree, ram_free);
	rti->physical_memory = ram;
	rti->physical_memory_avail = ram_free;
#ifdef GPAC_MEMORY_TRACKING
	rti->gpac_memory = gpac_allocated_memory;
#endif
	return 1;
}
/** Adjusts system time if required. The decision whether the adjustment is needed or not
is based on the following criterias:
 - satellite time must be present in the location update
 - time threshold must be exceeded
 - time from a last adjustment is greater than a defined interval.
 
@param aStatus An error code.
@param TPositionSatelliteInfo Position and time information. 
							  If clock adjustment takes place the TPosition::iTime is 
							  re-set to the satellite time.
@see CLbsAdmin
@see TPositionSatelliteInfo
*/
void CAutoClockAdjust::LocationUpdate(TInt aStatus, TPositionSatelliteInfo& aPosInfo)
	{
	LBSLOG(ELogP1, "CAutoClockAdjust::LocationUpdate()\n");
	TTimeIntervalMicroSeconds timeCorr;
	TTime sysTime;
	TInt err;
	
	// If adjustment on, no error, and satellite information present
	if ((iClockAdjustSetting == CLbsAdmin::EClockAdjustOn) && (aStatus == KErrNone) &&
	    ((aPosInfo.PositionClassType() & EPositionSatelliteInfoClass) == EPositionSatelliteInfoClass))
		{
		// Is is time do do another time adjustment?
		sysTime.UniversalTime();
		if (Abs(sysTime.MicroSecondsFrom(iLastAdjustment).Int64()) > (1000*iAdjustInterval))
			{
			const TPositionSatelliteInfo& satInfo = static_cast<const TPositionSatelliteInfo&>(aPosInfo);
			err = CalculateTimeCorrection(satInfo, timeCorr);
			if (err == KErrNone)
				{
				// Is threshold exceeded? 
				if (Abs(timeCorr.Int64()) > (1000*iAdjustThreshold))
					{
					sysTime.UniversalTime();
					sysTime += timeCorr;
					LBSLOG(ELogP9, "->S CGpsSetClockBase::SetUTCTime() ClockModule\n");
					LBSLOG5(ELogP9, "  > TTime sysTime  = %02d:%02d:%02d.%06d\n", sysTime.DateTime().Hour(), 
																				sysTime.DateTime().Minute(),
																				sysTime.DateTime().Second(),
																				sysTime.DateTime().MicroSecond());

					err = iSetClockImpl->SetUTCTime(sysTime);
					LBSLOG2(ELogP9, "  Return  = %d\n", err);

					if (err == KErrNone)
						{				
						// Sync the position time with the satellite time
						// to avoid re-adjusting the system time by the manual clock adjustment component.
						TPosition pos;
						aPosInfo.GetPosition(pos);
						pos.SetTime(aPosInfo.SatelliteTime());
						aPosInfo.SetPosition(pos);
						LBSLOG2(ELogP2, "ACTION: Clock Adjusted by %ld\n", timeCorr.Int64());
						}
					}
					
				if (err == KErrNone)
					{				
					// Remember the current time even if threshold not exceeded
					iLastAdjustment = sysTime;
					}
				else
					{
					LBSLOG_WARN2(ELogP3, "Clock Adjustment failed. Error: %d\n", err);
					}
				}
			}
		}
	}
TInt StopTimer(TTime aStartTimer)
	{
	TTime endTime;
	endTime.HomeTime();
		
	TTimeIntervalMicroSeconds duration = endTime.MicroSecondsFrom(aStartTimer);
	TInt actualDuration = I64INT(duration.Int64())/1000; // in millisecond
	return actualDuration;
	}
Example #11
0
jlong Os::java_time_millis() 
{
	TTime NineteenSeventy(_L("19700000:000000.000000"));
	TTime now;
	now.UniversalTime();
 	TTimeIntervalMicroSeconds interval = now.MicroSecondsFrom(NineteenSeventy);
	TInt64 time = interval.Int64() / 1000;
	return ((jlong)I64HIGH(time) << 32) | (jlong)I64LOW(time);
}
Example #12
0
// ---------------------------------------------------------
// ---------------------------------------------------------
//
void CPosTp143::CheckCountersL()
    {
    iLog->Log(_L("CheckCountersL"));

    TTime start, end;
    CPosLandmarkDatabaseExtended* dbExt = CPosLandmarkDatabaseExtended::OpenL();
    CleanupStack::PushL(dbExt);
    
    iLog->Log(_L("checking LandmarksCount"));
    start.UniversalTime();
    TInt lmCount = dbExt->LandmarksCount();
    end.UniversalTime();
    TTimeIntervalMicroSeconds interval = end.MicroSecondsFrom( start );
    iLog->Log(_L("LandmarksCount done in %ld us"), interval.Int64());
    
    if ( lmCount != iLandmarks.Count() )
        {
        iLog->Log( _L("LandmarksCount wrong result, expected %d, actual %d"),
            iLandmarks.Count(), lmCount );
        User::Leave( KErrGeneral );
        }

    CPosLmItemIterator* iter = iDatabase->LandmarkIteratorL();
    CleanupStack::PushL(iter);

    if ( lmCount != iter->NumOfItemsL() )
        {
        iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"),
            iter->NumOfItemsL(), lmCount );
        User::Leave( KErrGeneral );
        }

    CleanupStack::PopAndDestroy( iter );

    iLog->Log(_L("checking CategoriesCount"));
    start.UniversalTime();
    TInt catCount = dbExt->CategoriesCount();
    end.UniversalTime();
    interval = end.MicroSecondsFrom( start );
    iLog->Log(_L("CategoriesCount done in %ld us"), interval.Int64());
    
    CPosLmCategoryManager& catman = dbExt->CategoryManager();
    
    CPosLmItemIterator* catIter = catman.CategoryIteratorL();
    CleanupStack::PushL(catIter);
    
    if ( catCount != catIter->NumOfItemsL() )
        {
        iLog->Log( _L("CategoriesCount wrong result, expected %d, actual %d"),
            catIter->NumOfItemsL(), catCount );
        User::Leave( KErrGeneral );
        }

    CleanupStack::PopAndDestroy( catIter );
    CleanupStack::PopAndDestroy( dbExt );
    }
Example #13
0
TTimeIntervalMicroSeconds CWsSpriteManager::CalculateTimeToNextFlash(TTimeIntervalMicroSeconds aTime) const
	{
	TInt64 nextStateChange;
	if(aTime<KFlashHalfSecond)
		nextStateChange=KFlashHalfSecond-aTime.Int64();
	else
		nextStateChange=KFlashHalfSecond - (aTime.Int64() - KFlashHalfSecond);
	ASSERT(nextStateChange > 0);
	return TTimeIntervalMicroSeconds(nextStateChange);
	}	
Example #14
0
// -----------------------------------------------------------------------------
// CGameController::StartGameL
// Intializes the Game and Starts the game loop.
// -----------------------------------------------------------------------------
//
void CGameController::StartGameL( CGame& aGame )
{    
    iGame = &aGame;   
    
    // Allow the game to initialize itself.
    // The opengl es state intialization is done here.
    aGame.Initialize( iWindow->Size().iWidth, iWindow->Size().iHeight );
    
    TTime currentTime;
    TTime lastTimeVisited;
    lastTimeVisited.HomeTime();    
        
    while( 1 ) // Loop until the Game wants to exit.
    {       
        // Process any pending tasks.
        // This runs any Active objects that are waiting for 
        // some processing. 
        // The CWsEventReceiver Active Object gets a chance to
        // run here (on a key event for example).
        ProcessBackgroundTasks( EFalse );
                
        // If the application is not in focus or is not visible.
        // Block until it regains focus.
        while( EFalse == iIsAppInFocus || EFalse == iIsVisible )
            ProcessBackgroundTasks( ETrue );
                
        // Get the current time.
        currentTime.HomeTime();       
        TTimeIntervalMicroSeconds dur 
                    = currentTime.MicroSecondsFrom( lastTimeVisited );                        
                
        // The game renders itself using opengl es apis.
        // A return value of EFalse signifies an exit from the game.
        // Pass in the time (in micro secs) elapsed since last call. 
        if( EFalse == aGame.RenderFrame( dur.Int64() ) )
        {
            break;
        }                                

        // Call eglSwapBuffers, which blits the graphics to the window.
        eglSwapBuffers( iEglDisplay, iEglSurface );    

        // To keep the background light on.
        if( !( ( iGame->GetCurrentFrame() )%100 ) )
        {
            User::ResetInactivityTime();
        }
        
        // Store the last time the Game was rendered.
        lastTimeVisited = currentTime;
    }
    
    // Cleanup.
    aGame.Cleanup();    
}
TInt CStreamControl::GetDuration(TInt64& aDuration)
    {
    TInt status(KErrUnknown);
    TTimeIntervalMicroSeconds duration;
    status = iController.GetDuration(duration);
    if (status == KErrNone)
        {
        aDuration = duration.Int64();
        }
    return status;
    }
TInt CStreamControl::GetPosition(TInt64& aPos)
    {
    TInt status(KErrUnknown);
    TTimeIntervalMicroSeconds posInTime;
    status = iController.GetPosition(posInTime);
    if (status == KErrNone)
        {
        aPos = posInTime.Int64();
        }
    return status;
    }
Example #17
0
EXPORT_C TUint DataPosition(TTimeIntervalMicroSeconds aPosition,
					TTimeIntervalMicroSeconds aFrameTime,
					TUint aFrameLength)
	{
	TInt64 dataPosition64(0);

	if(aFrameTime.Int64() != 0)
		dataPosition64 = aPosition.Int64() * aFrameLength / aFrameTime.Int64() ;

	return I64INT(dataPosition64);
	}
Example #18
0
void CMMFDataPath2::FillSourceBufferL()
	{
	__ASSERT_DEBUG((iState == EPlaying || iState == EConverting || iState == ERecording || (iState == EPrimed && iPauseCalled && iIsUsingResumeSupport) ), Panic(EMMFDataPathPanicBadState,__LINE__)); 

	//if the silence timer is active then dont propagate the request
	if(iRepeatTrailingSilenceTimer->IsActive())
		{
		return;
		}
	
	//play the silence period and dont propagate the request
	if(iTrailingSilenceLeftToPlay>0 || iVerifyPlayComplete)
		{
		if(iVerifyPlayComplete)//case when the trailing silence is zero
			{
			if (!*iDisableAutoIntent && iDrmSource)
				{
				CMMFFile* file = static_cast<CMMFFile*>(iDrmSource);
				TInt err = file->ExecuteIntent(ContentAccess::EPlay);
				if (err != KErrNone)
					{
					DoSendEventToClient(KMMFEventCategoryPlaybackComplete, err);
					return;
					}
				}
			
			//Retrieve the current play time and add "duration-currentplaytime" to the silence period
			//This is to ensure that silence timer is not started before the previous play is actually completed by the devsound
			TTimeIntervalMicroSeconds currentTime = CalculateAudioOutputPosition();
			if(currentTime.Int64()>iPlayWindowStartPosition.Int64())
				{
				iTimeLeftToPlayComplete = iPlayWindowEndPosition.Int64()-currentTime.Int64();
				}
			else
				{
				iTimeLeftToPlayComplete = 0;
				}

			iVerifyPlayComplete = EFalse;
			}
		if(iTrailingSilenceLeftToPlay==0 && iTimeLeftToPlayComplete==0)
			{
			SetPositionL(iPlayWindowStartPosition);
			iTimeLeftToPlayComplete=-1;
			}
		else
			{
			PlaySilence();
			return;
			}
		}
	
	DoFillSourceBufferL();
	}
Example #19
0
TInt64 TimeUtils::GetFiletime(TTime aSymbianTime)
	{
	_LIT(KInitialTime,"16010000:000000");
	TTime initialTime;
	initialTime.Set(KInitialTime);
			
	TTimeIntervalMicroSeconds interval;
	interval=aSymbianTime.MicroSecondsFrom(initialTime);
		
	return interval.Int64()*10; 
		
	}
void CSmilTranslatorTestUtils::ComposeFileCompleteL()
// call back function called from Composer::RunL()
	{
	TTime timeNow;
	timeNow.UniversalTime();
	TTimeIntervalMicroSeconds timeForCompose = timeNow.MicroSecondsFrom(iStartComposeTime);
	iComposeTime += timeForCompose.Int64();

	if (iComposerState == ESizing)
		{
		// Check the size of the file that has been written against the size calulated by the
		// call to CMDXMLComposer::CalculateFileSize

		RFile outputXMLFile;
		outputXMLFile.Open(iSession, iOutputFileName, EFileRead);

		TInt actualSize;
		User::LeaveIfError(outputXMLFile.Size(actualSize));
		
		if (iSize != actualSize)
			{
			// The calculated file size doesn't match the real file size, this test has failed
			TBuf<255> outputMsg;

			outputMsg.Append(KOutputNewLine);
			outputMsg.Append(_L("Test Failed - The calculated file size doesn't match the actual size."));
			outputMsg.Append(KOutputNewLine);			
			
			test.Printf(outputMsg);						// print to console
			iErrorFile.Write(DES_AS_8_BIT(outputMsg));	// print to error file			
			}

		outputXMLFile.Close();

		// If we are sizing then stop the active scheduler. Once the scheduler is stopped
		// and this function exits, program control resumes where the scheduler was started
		// in RunTestL.
//		CActiveScheduler::Stop();
		}

	else if (iComposerState == EComposing)
		{
		// The XML file has been composed. Now we need to run the sizing function to check
		// that we can calculate the size correctly.

		// Set the state to sizing and run the sizing operation...
		iComposerState = ESizing;

		// Calculate the file size and wait for the callback to this function again.
		iComposer->CalculateFileSize(iSize, iXMLDoc, testConfig->FileType());
		}
	}
Example #21
0
void CHttpHdrTest::DisplayTimeElapsed()
// Calculate elapsed time since last measurement, and display
	{
	TTime timeNow;
	timeNow.UniversalTime();
	TTimeIntervalMicroSeconds elapsedMicroSec =
									timeNow.MicroSecondsFrom(iLastTimeStamp);
	iLastTimeStamp = timeNow;
	iEngine->Console().Printf(
		_L("Time elapsed since last measurement is: %d ms\n"),
		elapsedMicroSec.Int64()/1000
		);
	}
Example #22
0
    EXPORT_C clock_t clock ()
    {
        int retval=-1;
        RThread proc;
        TTimeIntervalMicroSeconds iMicSecsFromEpoc;
        TInt err=proc.GetCpuTime(iMicSecsFromEpoc);

        if(err)
        {
            return retval;
        }
        return I64INT(iMicSecsFromEpoc.Int64());
    }
Example #23
0
// Returns the time the current thread has spent executing, in milliseconds.
static inline unsigned getCPUTime()
{
#if OS(DARWIN)
    mach_msg_type_number_t infoCount = THREAD_BASIC_INFO_COUNT;
    thread_basic_info_data_t info;

    // Get thread information
    mach_port_t threadPort = mach_thread_self();
    thread_info(threadPort, THREAD_BASIC_INFO, reinterpret_cast<thread_info_t>(&info), &infoCount);
    mach_port_deallocate(mach_task_self(), threadPort);
    
    unsigned time = info.user_time.seconds * 1000 + info.user_time.microseconds / 1000;
    time += info.system_time.seconds * 1000 + info.system_time.microseconds / 1000;
    
    return time;
#elif OS(WINDOWS) 
	union {
		FILETIME fileTime;
		unsigned long long fileTimeAsLong;
	} userTime, kernelTime;
    
    // GetThreadTimes won't accept NULL arguments so we pass these even though
    // they're not used.
    FILETIME creationTime, exitTime;
    
    GetThreadTimes(GetCurrentThread(), &creationTime, &exitTime, &kernelTime.fileTime, &userTime.fileTime);
    
    return userTime.fileTimeAsLong / 10000 + kernelTime.fileTimeAsLong / 10000;
#elif OS(SYMBIAN)
    RThread current;
    TTimeIntervalMicroSeconds cpuTime;

    TInt err = current.GetCpuTime(cpuTime);
    ASSERT_WITH_MESSAGE(err == KErrNone, "GetCpuTime failed with %d", err);
    return cpuTime.Int64() / 1000;
#elif PLATFORM(BREWMP)
    // This function returns a continuously and linearly increasing millisecond
    // timer from the time the device was powered on.
    // There is only one thread in BREW, so this is enough.
    return GETUPTIMEMS();
#else
    // FIXME: We should return the time the current thread has spent executing.

    // use a relative time from first call in order to avoid an overflow
    static double firstTime = currentTime();
	//+EAWebKitChange
	//10/17/2011 - Added explicit cast.
	return static_cast<unsigned> ((currentTime() - firstTime) * 1000);
	//-EAWebKitChange
#endif
}
static void PerformanceTest2L()
{
	test.Printf(_L("\nHuge Ini file(684Kb) performance test\n"));
	//This test will try finding values within different section in the ini file, beginning
	//middle and end of the file.
	//Light weight testing
	TTime startTime, stopTime;

	TPtrC16 value;
	startTime.UniversalTime();
for (TInt i=0;i<1;i++)
	{
	CIniFile16* ini=CIniFile16::NewL(TheRFs,_L("z:\\resource\\big16.ini"));
	test(ini->FindVar(_L("Secure_DB_Backup"),_L("source"),value)==KErrNone);
	test(value.Compare(_L("C:\\private\\100012a5\\DBS_100065FF_performance.cdb"))==0);
	test(ini->FindVar(_L("20701_AddEntries"),_L("firstname430"),value)==KErrNone);
	test(value.Compare(_L("Husham"))==0);
	test(ini->FindVar(_L("20701_AddEntries"),_L("homemobile514"),value)==KErrNone);
	test(value.Compare(_L("07763 222730"))==0);
	test(ini->FindVar(_L("20701_AddEntries"),_L("dummyI830"),value)==KErrNone);
	test(value.Compare(_L(""))==0);
	test(ini->FindVar(_L("20701_AddEntries"),_L("workemail1066"),value)==KErrNone);
	test(value.Compare(_L("*****@*****.**"))==0);
	delete ini;
	}
	stopTime.UniversalTime();
	TTimeIntervalMicroSeconds timeTaken = stopTime.MicroSecondsFrom(startTime);
	test.Printf(_L("Time taken for Light= %d microseconds\n"), timeTaken.Int64() );

	//heavy weight testing
	startTime.UniversalTime();
for (TInt j=0;j<1;j++)
	{
	CIniDocument16* dom=CIniDocument16::NewL(TheRFs,_L("z:\\resource\\big16.ini"));
	test(dom->GetKeyValue(_L("Secure_DB_Backup"),_L("source"),value)==KErrNone);
	test(value.Compare(_L("C:\\private\\100012a5\\DBS_100065FF_performance.cdb"))==0);
	test(dom->GetKeyValue(_L("20701_AddEntries"),_L("firstname430"),value)==KErrNone);
	test(value.Compare(_L("Husham"))==0);
	test(dom->GetKeyValue(_L("20701_AddEntries"),_L("homemobile514"),value)==KErrNone);
	test(value.Compare(_L("07763 222730"))==0);
	test(dom->GetKeyValue(_L("20701_AddEntries"),_L("dummyI830"),value)==KErrNone);
	test(value.Compare(_L(""))==0);
	test(dom->GetKeyValue(_L("20701_AddEntries"),_L("workemail1066"),value)==KErrNone);
	test(value.Compare(_L("*****@*****.**"))==0);
	delete dom;
	}
	stopTime.UniversalTime();
	timeTaken = stopTime.MicroSecondsFrom(startTime);
	test.Printf(_L("Time taken for Heavy= %d microseconds\n"), timeTaken.Int64() );

}
Example #25
0
// returns the duration of the source clip
TTimeIntervalMicroSeconds CMMFRawFormatRead::Duration(TMediaId aMediaId) const
	{
	if ((aMediaId.iMediaType == KUidMediaTypeAudio) && 
		(iClipLength) && (iSampleRate) && (iBitsPerSample) && (iChannels))
		{//we have enough values to calculate the duration
		TInt64 clipLength(iClipLength);
		clipLength*=KOneSecondInMicroSeconds;
		TTimeIntervalMicroSeconds duration = TTimeIntervalMicroSeconds(clipLength/iSampleRate);
		duration = TTimeIntervalMicroSeconds(duration.Int64()/(iBitsPerSample*iChannels));
		duration = TTimeIntervalMicroSeconds(duration.Int64()*8);
		return duration;
		}
	else return TTimeIntervalMicroSeconds(0);
	}
uint32
SymbianFileHandler::getModificationDate() const
{
   // The day the unix time starts. Used to get the time down
   // to a reasonable value.
   TDateTime epoch( 1970, EJanuary, 01, 0 , 0 , 0 , 0);
   TTime aTime( epoch );
   TInt res = m_fileServer.Modified( *m_fileName16, aTime );
   if ( res != KErrNone ) {
      return MAX_UINT32;
   }
   TTimeIntervalMicroSeconds interval = aTime.MicroSecondsFrom( epoch );   
   return LOW( interval.Int64() / 1000000 );
}
Example #27
0
void AvkonMedia::Rewind(TInt aIntervalInSeconds)
	{
	iPlayerUtility->Pause();

	// Get the current position of the playback.
	TTimeIntervalMicroSeconds position;
	iPlayerUtility->GetPosition(position);

	// Add the interval to the current position.
	position = position.Int64() - aIntervalInSeconds * KOneSecond;

	// Set the new position.
	iPlayerUtility->SetPosition(position);
	iPlayerUtility->Play();
	}
Example #28
0
void AvkonMedia::FastForward(TInt aIntervalInSeconds)
	{
	iPlayerUtility->Pause();

	// Get the current position of the playback.
	TTimeIntervalMicroSeconds position;
	iPlayerUtility->GetPosition(position);

	// Subtract the interval from the current position.
	position = position.Int64() + aIntervalInSeconds * KOneSecond;

	// Set the new position.
	iPlayerUtility->SetPosition(position);
	iPlayerUtility->Play();
	}
/*
*Computes time difference between first two parameters and prints them in the log file.
*@param aStartTime 	The start time of the operation
*@param	aEndTime	The end time of the operation
*@param aMaxTimeLimit Time taken for the entries without attachment in v9.2
*@return timeTakenForOperation
*/
TReal32 CTestCalInterimApiSuiteStepBase::CalculateTimeDifference(const TTime& aStartTime, const TTime& aEndTime, const TReal32& aMaxTimeLimit)
	{
	TTimeIntervalMicroSeconds timeElapsed = aEndTime.MicroSecondsFrom(aStartTime);

	TReal32 timeTakenForOperation = (static_cast<TReal32>(timeElapsed.Int64())) / (1000000);

	if ((timeTakenForOperation > aMaxTimeLimit))
		{
		INFO_PRINTF1(_L("The time taken for entries with attachment is more"));
		INFO_PRINTF2(_L("Time Taken for entries without attachment in v9.2 is --> %fseconds"), aMaxTimeLimit);
		INFO_PRINTF2(_L("Time Taken for entries with attachment is --> %fseconds"), timeTakenForOperation);
		}

	return timeTakenForOperation;
	}
Example #30
0
void CProtocolExadump::DoPacket(const RMBufPacketBase &aPacket, const RMBufPktInfo &aInfo)
	/**
	* Dump the packet.
	*
	* This is called for both incoming and outgoing packets, from the
	* respective ApplyL methods.
	*
	* @param aPacket	The packet data
	* @param aInfo		The packet inforrmation
	*/
	{
/** @code */
	// Open the dump file, if not already opened (or attempted).
	if (iOpen == 0)
		DoOpen(1500);
	if (iOpen < 0)
		return;	// cannot open output file.

	//
	// Build PCAP frame into iBuffer (pcap_pkthdr + snapped portion of the packet)
	//
	TPtr8 buf = iBuffer->Des();
	struct pcap_pkthdr *const hdr = (struct pcap_pkthdr *)buf.Ptr();
	TPtr8 ptr((TUint8 *)buf.Ptr() + sizeof(*hdr), buf.MaxLength() - sizeof(*hdr));

	const TInt snap = aInfo.iLength > ptr.MaxLength() ? ptr.MaxLength() : aInfo.iLength;
	ptr.SetLength(snap);
	aPacket.CopyOut(ptr);

	hdr->caplen = snap;
	hdr->len = aInfo.iLength;

	TTime stamp;
	stamp.UniversalTime();
	const TTimeIntervalMicroSeconds elapsed = stamp.MicroSecondsFrom(iBase);
#ifdef I64INT
	hdr->ts.tv_usec = I64INT(elapsed.Int64() % 1000000);
	hdr->ts.tv_sec = I64INT(elapsed.Int64() / 1000000);
#else
	hdr->ts.tv_usec = (elapsed.Int64() % 1000000).GetTInt();
	hdr->ts.tv_sec = (elapsed.Int64() / 1000000).GetTInt();
#endif
	//
	// Write frame out.
	//
	iDumpFile.Write(buf, snap+sizeof(*hdr));
/** @endcode */
	}