2012. 7. 13. 16:40

#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/times.h>

static void showtimes(void) {
   double ticks;
   struct tms tinfo;

   if ((ticks = (double) sysconf(_SC_CLK_TCK)) == -1)
      perror("Failed to determine clock ticks per second");
   else if (times(&tinfo) == (clock_t)-1)
      perror("Failed to get times information");
   else {
      fprintf(stderr, "User time:              %8.3f seconds\n",
         tinfo.tms_utime/ticks);
      fprintf(stderr, "System time:            %8.3f seconds\n",
         tinfo.tms_stime/ticks);
      fprintf(stderr, "Children's user time:   %8.3f seconds\n",
         tinfo.tms_cutime/ticks);
      fprintf(stderr, "Children's system time: %8.3f seconds\n",
         tinfo.tms_cstime/ticks);
   }
}

int main(void) {
   if (atexit(showtimes))  {
      fprintf(stderr, "Failed to install showtimes exit handler\n");
      return 1;
   }
    /*  rest of main program goes here */
   return 0;
}

User time:                 0.000 seconds
System time:               0.000 seconds
Children's user time:      0.000 seconds
Children's system time:    0.000 seconds

'EMBEDDED > SYSTEM Proc' 카테고리의 다른 글

[analysis] lint, splint  (0) 2012.07.13
[Process] n개의 프로세스 체인을 만드는 프로그램  (0) 2012.07.13
[Make] Make 사용법  (0) 2012.07.13
[Library] Library 만들기  (0) 2012.07.13
[Gcc] 관련 메뉴얼  (0) 2012.07.13
Posted by 몰라욧