clock_t
From cppreference.net
|
헤더 파일에 정의됨
<time.h>
|
||
|
typedef
/* unspecified */
clock_t
;
|
||
산술 (C11까지) 실수 (C11부터) 프로세스가 사용한 프로세서 시간을 나타낼 수 있는 타입. 구현체 정의 범위와 정밀도를 가짐.
예제
이 코드 실행
#include <stdio.h> #include <time.h> #include <math.h> volatile double sink; int main (void) { clock_t start = clock(); for(size_t i=0; i<3141592; ++i) sink+=sin(i); clock_t end = clock(); double cpu_time_used = ((double) (end - start)) / CLOCKS_PER_SEC; printf("for loop took %f seconds to execute \n", cpu_time_used); }
가능한 출력:
for loop took 0.271828 seconds to execute
참고문헌
- C17 표준 (ISO/IEC 9899:2018):
-
- 7.27.1/3 시간 구성 요소 (p: 284)
- C11 표준 (ISO/IEC 9899:2011):
-
- 7.27.1/3 시간 구성 요소 (p: 388)
- C99 표준 (ISO/IEC 9899:1999):
-
- 7.23.1/3 시간 구성 요소 (p: 338)
- C89/C90 표준 (ISO/IEC 9899:1990):
-
- 4.12.1 시간 구성 요소
참고 항목
|
프로그램 시작 이후의 원시 프로세서 클럭 시간을 반환합니다
(함수) |
|
|
초당 프로세서 클럭 틱 수
(매크로 상수) |
|
|
C++ documentation
for
clock_t
|
|