關於部落格
  • 26394

    累積人氣

  • 0

    今日人氣

    0

    訂閱人氣

show_per_sec.c

/* A example of TCP echo server File : TCPEchoServer.cpp */ #include #include #include #include #include //#include #include #include #include //#include #include #include #include #include #include #include #include #include #include #include //#include #include #include //#include "creator_s3c4510_lcd.h" //#include "creator_lib.h" //#include "creator_lib.c" //#include "lcd-creator.h" #define PROMPT "3 seconds haved been passedna" char *prompt=PROMPT; unsigned int len,k=0; struct timeval tpnew,tpold; float timeuse; void timeout(int signo) { tpold=tpnew; gettimeofday(&tpnew,NULL); timeuse=1000000*(tpnew.tv_sec-tpold.tv_sec)+tpnew.tv_usec-tpold.tv_usec; // timeuse/=1000000; printf("Used Time:%fn",timeuse); printf("%dn",k); k++; } void init_sigaction(void) { struct sigaction act; act.sa_handler=timeout; act.sa_flags=0; sigemptyset(&act.sa_mask); // // sigaction(SIGPROF,&act,NULL); sigaction(SIGALRM,&act,NULL); } void init_time() { struct itimerval value; value.it_value.tv_sec=0; value.it_value.tv_usec=500000; //1.5*2=3sec value.it_interval=value.it_value; // setitimer(ITIMER_PROF,&value,NULL); setitimer(ITIMER_REAL,&value,NULL); } int main() { unsigned int i=1; double y; //y=exp(10); // y=sqrt((double)i); len=strlen(prompt); init_sigaction(); init_time(); while(1) { unsigned int i,j; double y; for(i=1;i<5000;i++) { j=rand(); y=sin((double)j); } // printf("sleep %d ..n",y); } exit(0); }
相簿設定
標籤設定
相簿狀態