C ++ high-precision computing code running time

Source: Internet
Author: User
// Call the queryperformancefrequency () function to obtain the clock frequency of the timer. // call queryperformancecounter () before and after events that require strict timing, and use the difference in counting and clock frequency obtained twice, the precise time of the event experience can be calculated. // the high-precision timer for Win9x: queryperformancefrequency () and queryperformancecounter (). The computer must support high-precision timer on hardware. // The data type largeinteger can be an 8-byte long integer or a union structure of two 4-byte long integers, the specific usage depends on whether the compiler supports 64-bit. large_integer frequency = {0}; queryperformancefrequency (& frequency); double F = (double) frequency. quadpart; queryperformancecounter (& frequency); Longlong I = frequency. quadpart; {// do something here} queryperformancecounter (& frequency); string result; result. format (_ T ("Result: % F"), double (frequency. quadpart-I)/F); MessageBox (null, P, _ T ("Test Report"), mb_ OK );

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.