Symbian time usage and statistical (Computing) function (class) running time

Source: Internet
Author: User

(1) tTime: hometime ()/tTime: universaltime ()

The most common time acquisition method has a low accuracy. because it involves a certain calculation process, the efficiency is low. It is applicable to the scenario where the time needs to be used in the conventional "year, month, day, hour, minute, second" mode. On the eka2 platform, the precision is the same as that of the low-level system clock (nanokernel timer. The specific precision obtained through Hal: Get (HAL: enanotickperiod, result.
Note: they use system time, which can be modified by other processes.

(2) User: tickcount ()

Traditional tick counters have a precision of only 1/64 seconds (which may vary with hardware) and are suitable for low precision scenarios. You can obtain the specific precision through Hal: Get (HAL: esystemtickperiod, result.
Note: In the standby status, tickcount stops counting, soUser: tickcount (): "lost" in sleep state!

(3) User: ntickcount ()

The low-level system clock (nanokernel timer) usually provides a subtle level of tick. You can obtain the specific precision through Hal: Get (HAL: enanotickperiod, result.
Note: This API is unavailable for Symbian OS 6.x. Different from tickcount, user: ntickcount () does not "lose" time in sleep state.

(4) User: fastcounter ()

The returned value is similar to tick. It provides the highest precision supported by Symbian OS, which is generally more accurate than tTime: hometime. (If the hardware does not support high resolution timer, the clock will be replaced in milliseconds) and it is very efficient because it uses the fast exec call to read the value of a hardware register. You can use HAL: Get (haldata: efastcounterfrequency, result) to obtain the specific precision.
Note: after each terminal is activated from the sleep state, it will be synchronized to the correct value, that is, the user: fastcounter () in the sleep state is not "lost" timing.

In addition, user: After (), cperiodic will also "lose" timing in sleep state, so in a special application environment such as mobile phones, pay special attention to the timing difference of different timers in the sleep state.

Attached to the submitter:

(2) the method mentioned in is as follows:

Tint period;
User: leaveiferror (HAL: Get (haldata: esystemtickperiod, period ));
Tint logmillisecspertick = period/1000;
Tbuf <50> text;

Tint timeinmillisecs = User: tickcount () * logmillisecspertick;
Tint secs = timeinmillisecs/1000;
Tint millisecs = timeinmillisecs % 1000;
Text. Num (SECs );
Text. append ('.');
Text. Num (millisecs); // second. The precision of milliseconds is usually only 1/64 seconds (may vary with hardware). It is 1/100 seconds on the simulator,

Showtextonscreen (text );



Count function running time


TTime lasttime;

TTime currenttime;
Lasttime. hometime ();
Func ();
Currenttime. hometime ();

# Ifdef _ series60_30 __
Tint64 timelasted64 = (currenttime. int64 ()-lasttime. int64 ());
Tuint timelasted = (tuint) cnt64;
# Else
Tuint timelasted = (currenttime. int64 ()-lasttime. int64 (). Low ();
# Endif

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.