[C Language] program execution time measurement

Source: Internet
Author: User

During the creation of a big data file today, in order to measure the Creation Time, I studied how to obtain the time in windows.

1. Timing of 55 ms Resolution:

Header file: # include

GetTickCount () usage:

DWORD dwStart = GetTickCount ();
Functon (); // Your program.
DWORD dwEnd = GetTickCount ();
DWORD dwTimes = dwEnd-dwStart;

2. 10 ms resolution timing:

Header file:

# Include
# Include
# Pragma comment (lib, "winmm. lib ")

TimeGetTime () usage:

DWORD dwStart = timeGetTime ();
Function; // Your program
DWORD dwEnd = timeGetTime ();
DWORD dwTimes = dwEnd-dwStart;

3. 1 ms resolution timing:

Header file:

# Include

Clock () usage:

Clock_t s_time = clock ();

Function ();

Clock_t e_time = clock ();

Clock_t time = e_time-s_time;

 

 

Here with the full information: http://blog.csdn.net/cometdlut/article/details/5839348

Related Article

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.