clock

호출 프로세스에 의해 사용 되는 벽 시계 시간을 계산 합니다.

clock_t clock( void );

반환 값

프로세스가 시작 된 이후 경과 된 벽 시계 시간 (경과 된 시간을 초로 시간 CLOCKS_PER_SEC).경과 된 시간을 사용할 수 없는 경우 – 1로 캐스팅할 함수 반환 된 clock_t.

설명

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. 자세한 내용은 플랫폼 호출 예제.

참고 항목

참조

시간 관리

difftime, _difftime32, _difftime64

time, _time32, _time64