본문 바로가기

컴퓨터 과학 & 영상처리 관련/C / C++

노트북과 i-2100 수행시간 비교..(시작 시간, 종료 시간 출력 등)

노트북 놀리기도 아깝고..그냥 c언어 연습좀 할라 하는데 리눅스 깔라면 맨날 안되서

걍 devcpp 깔고 c프로그램 아무거나 돌리기로함

시작 시간과 종료 시간을 출력하고 싶은데 그런 함수가 c언어에도 있다네...

검색해보니깐 여기가 자세하게 정리 잘 해놓은듯

난 그냥 갖다 쓰는거지머...

 

http://blog.naver.com/PostView.nhn?blogId=6k5tvb&logNo=120056129540

 

 

 

 소스

 
#include <stdio.h>
#include <time.h>

void printTime(struct tm *today,char * str)
{
printf("%5s = %04d-%02d-%02d %02d:%02d:%02d",
str,
today->tm_year+1900,
today->tm_mon+1,
today->tm_mday,
today->tm_hour,
today->tm_min,
today->tm_sec);
}


int main(void)
{
unsigned int j=0xffffffff;
int i,k;
time_t startTime;
time_t endTime;
struct tm *today;

time(&startTime);
today = localtime(&startTime);



for(i=0;i<j;i++)
{
if((i & 0xf0000000)>0)
k=8;
else if((i & 0xff000000)>0)
k=7;
else if((i & 0xfff00000)>0)
k=6;
else if((i & 0xffff0000)>0)
k=5;
else if((i & 0xfffff000)>0)
k=4;
else if((i & 0xffffff00)>0)
k=3;
else if((i & 0xfffffff0)>0)
k=2;
else if((i & 0xffffffff)>0)
k=1;

printf("i = %08x, %d",i,k);
}


printTime(today,"start");

time(&endTime);
today = localtime(&endTime);

printTime(today,"end");

getchar();
return 0;
}

 

 

노트북이랑 i-2100이랑 동시에 해서...몇초가 걸리는지 비교하려함

의외로 이 단순한 프로그램 끝나는데 엄청나게 많은 시간이 걸림

호오...그런 이런저런 실험용으로 옛날 노트북을 쓰는것도 나쁘지 않겠다 생각함

 

 

근데 printf 하면 시간 넘 오래 걸리는데 (몇시간 넘게 걸림..노트북이던 본체던)

printf빼면 1분이면 끝남...디스어셈블을 해보기로함

 

 

 

  else if((i & 0xffffffff)>0)
00E51551 cmp dword ptr [i],0
00E51555 jbe main+0EEh (0E5155Eh)
   k=1;
00E51557 mov dword ptr [k],1

//printf("i = %08x, %d\n",i,k);
}
00E5155E jmp main+49h (0E514B9h)

 

 

     else if((i & 0xffffffff)>0)
00DE158F  cmp         dword ptr [i],0 
00DE1593  jbe         main+133h (0DE15A3h) 
                          k=1;                         
00DE1595  mov         byte ptr [ebp-115h],1 
00DE159C  mov         dword ptr [k],1 

  printf("i = %08x, %d\n",i,k);
00DE15A3 cmp byte ptr [ebp-115h],0
00DE15AA jne main+149h (0DE15B9h)
00DE15AC push offset (0DE1682h)
00DE15B1 call @ILT+165(__RTC_UninitUse) (0DE10AAh)
00DE15B6 add esp,4
00DE15B9 mov esi,esp
00DE15BB mov eax,dword ptr [k]
00DE15BE push eax
00DE15BF mov ecx,dword ptr [i]
00DE15C2 push ecx
00DE15C3 push offset string "i = %08x, %d\n" (0DE5774h)
00DE15C8 call dword ptr [__imp__printf (0DE82ECh)]
00DE15CE add esp,0Ch
00DE15D1 cmp esi,esp
00DE15D3 call @ILT+305(__RTC_CheckEsp) (0DE1136h)
}
00DE15D8 jmp main+50h (0DE14C0h)


위랑 아래랑 비교하면 일단 길이부터 존나 차이나긴 하지만...그 사이에 메모리를 많이 사용하는게 보임

아마 메모리의 속도가 느리기 때문에 그런거 같음..

 

 

 


 

printf를 배면 i-2100의 경우 10초, 노트북의 경우 24초
노트북 메모리 & 하드가 느려서 그런거 같은데 넘 아깝다..
빠른 메모리로 바꾸면 메인보드에서 동작이 할지 안할지도 모르고 참..