[C ++] C ++ time

xiaoxiao2021-03-06  54

Time in C

#include

#include

#include

#include

#include

#include

#include

Using namespace std;

INT _Tmain (int Argc, _tchar * argv [])

{

Clock_t start, end;

// Macro definition: __ Date __, __ Time __, __ file __, __ line__, indicating information in code compile.

String datecode = __date__; // Date of file compile.

String timecode = __time__; // The time when the file is compiled.

Cout << "Creat The Software of Date: << Datecode << Endl;

Cout << "Creat The Software of Time: << Timecode << Endl;

Start = clock (); // The program is running to the statistical CPU runtime, at which point value is 0.

_Getch (); // Press any one button to continue execution.

End = clock (); // Statistical time after pressing the key.

Cout << "press any key to continue" << Endl;

// Due to the end and START for milliseconds, it will be turned to a second value with CLK_TCK.

COUT << "Program Run Time:" << (end - start) / clk_tck << "snceond."

Return 0;

}

You can use the Clock to statistical the time length of the program run.

Time returns from January 1, 1970 to the current number of seconds, that is, system time.

The clock is started from the process After this process uses the total number of milliseconds of the CPU, which is often used to test the speed of the task execution.

转载请注明原文地址:https://www.9cbs.com/read-114523.html

New Post(0)