Date and time, timing

Source: Internet
Author: User

Each time you call localtime, it will overwrite a static structure and return the address of the structure (so at the same time inProgramOnly one such structure can be obtained, but no obvious copy can be made ). Strftime format the string according to the specified format (for example, % A represents the name of every day of the week ).

Http://develop.csai.cn/c/200805211459491305.htm

 

Localtime is NOT thread-safe, so using localtime in multiple threads may cause memory leakage.

Time_t now;

Time (& now); // The unit of the retrieved data is seconds.

Clock_t clockk;

Clockk = clock (); // million seconds millisecond, clocks_per_sec

Sleep (1000); Unit: milliseconds

Timer In cwnd cannot be accurate to milliseconds, and it is costly to use timer in cwnd. Because timer is derived from cwnd, As long as timer is used, it must have a cwnd object.

In the MFC class library, the following Windows API functions are encapsulated:

(1) timegetdevcaps to obtain the time precision of the current computer. Timecaps is a structure defined by the system.

(2) timebeginperiod: sets the precision of the current timer. This step is set to 5, indicating that the error is not greater than 5 ms.

(3) timeendperiod, which corresponds to 2, ends the timing precision.

(4) timesetevent. At the beginning of the timer, this function requires a number of callback letters and the parameters of the callback function as parameters. This program calls internaltimerproc, and the data struct parameter of mmrecord. This struct parameter specifies the timer ID and a pointer to the cmmstimers (which points to the timer ). (5) timekillevent. Terminate the timer.

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: info-contact@alibabacloud.com 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.