clock
호출 프로세스에서 사용 하는 시계 시간을 계산 합니다.
clock_t clock( void );
반환 값
프로세스가 시작 된 이후에 경과 된 벽 시계 시간 (CLOCKS_PER_SEC 초시간에서의 경과된 시간)입니다. 경과 된 시간을 사용할 수 없는 함수는 clock_t 를 캐스트로 -1을 반환합니다.
설명
clock 함수는 호출 프로세스에 사용 되는 시간을 알려 줍니다. 타이머 틱은 약 1 /CLOCKS_PER_SEC 초와 같습니다.
요구 사항
루틴 |
필수 헤더 |
---|---|
clock |
<time.h> |
호환성에 대한 자세한 내용은 소개 단원의 호환성 부분을 참조하십시오.
예제
// crt_clock.c
// This example prompts for how long
// the program is to run and then continuously
// displays the elapsed time for that period.
//
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void sleep( clock_t wait );
int main( void )
{
long i = 6000000L;
clock_t start, finish;
double duration;
// Delay for a specified time.
printf( "Delay for three seconds\n" );
sleep( (clock_t)3 * CLOCKS_PER_SEC );
printf( "Done!\n" );
// Measure the duration of an event.
printf( "Time to do %ld empty loops is ", i );
start = clock();
while( i-- )
;
finish = clock();
duration = (double)(finish - start) / CLOCKS_PER_SEC;
printf( "%2.1f seconds\n", duration );
}
// Pauses for a specified number of milliseconds.
void sleep( clock_t wait )
{
clock_t goal;
goal = wait + clock();
while( goal > clock() )
;
}
해당 .NET Framework 항목
해당 사항 없음. 표준 C 함수를 호출하려면 PInvoke를 사용합니다. 자세한 내용은 플랫폼 호출 예제를 참조하십시오.