Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Using timers

From Wiki
Jump to: navigation, search
Article Metadata
Article
Keywords: UniversalTime, FastCounter, NTickCount
Created: gafgafgaf (05 Jun 2007)
Last edited: hamishwillee (20 Oct 2011)
Developers have several options to profile application behavior with timers. Each of these options have advantages and disadvantages.

Contents

TTime::UniversalTime()

  • Resolution is in the microseconds range (on EKA2).
  • This timer uses the system time that can be changed by other programs
  • Tick period can be obtained by calling
TInt tickPeriod;
HAL::Get(HAL::ENanoTickPeriod, tickPeriod);

User::FastCounter()

  • Highest possible resolution of a Symbian OS timer
  • Faster than TTime::UniversalTime()
  • Tick period can be obtained by calling
TInt tickPeriod;
HAL::Get(HALData::EFastCounterFrequency, tickPeriod);

User::NTickCount() / NKern::TickCount()

  • Allows access to kernel tick count directly (user and kernel side)
  • does not lose time when device goes into standby
  • Tick period can be obtained by calling
HAL::Get(HAL::ENanoTickPeriod, tickPeriod); // User side
// or
TInt tickPeriod = NKern::TickPeriod() // Kernel side

Example code

This sample illustrates a way to calculate the time elapsed between two calls using TTime::UniversalTime().

...
TReal iFps; // frame per seconds
TTime iOldTime;
...
void CMyActiveObject::RunL()
{
TTime time;
time.UniversalTime();
// You may need to make sure that time counter is incremented
// to avoid division by zero
iFps = 1000000 / time.MicroSecondsFrom( iOldTime ).Int64();
iOldTime = time;
}
This page was last modified on 20 October 2011, at 04:19.
55 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×