c++ 실행시간 측정방법   article search result : 1

1) 밀리세컨트로 측정방법

#include < stdio.h >
#include < windows.h >

void main()
{
 int i =0 ;
 DWORD start ;
 DWORD end ;

 start = GetTickCount();

//start -- 측정하고싶은 코드 부분 --

for(i=0 ; i < 1000; i++)
 {
  printf("*"); }

//end

 end = GetTickCount();

 printf("\n실행시간 : %lf \n" , (end - start) / (double)1000 );
}

windows.h에 있는 GetTickCount를 사용.

maybe GetTickCount는  CPU시간을 밀리세컨드 단위로 리턴할것이다.

2) 다른방법

clock_t start;

clock_t end;

 

start = clock();

 

//코드부분

 

end = clock();

 

printf("%lf ms elapsed\n", end - start);

 


,
*1 
rss
count total , today , yesterday
I am
알립니다
분류 전체보기 (81)
Hmmm... (5)
Days & Days (34)
Study (7)
관심관심 (5)
Programming (19)
최근에 쓴 글
최근에 달린 댓글
최근에 연결된 관련글
글 보관함
달력
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31