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

main()

{
 long tps;
 struct tms time_buf0,time_buf1;
 clock_t rt0,rt;
 clock_t ut;
 clock_t st;
  
 tps=sysconf(_SC_CLK_TCK);
 rt0=times(&time_buf0);

 {
  long i;

  for(i=0;i<10000000;i++)
      fflush(stdin);
 }

 rt=times(&time_buf1) - rt0;

 ut = time_buf1.tms_utime - time_buf0.tms_utime;
 st = time_buf1.tms_stime - time_buf0.tms_stime;

 ut=ut*1000/tps;
 st=st*1000/tps;
 rt=rt*1000/tps;
 
 printf("\n real=%g user=%g syst=%g (cput=%g)\n",
        (double) rt/1000,
        (double) ut/1000,
        (double) st/1000,
        (double) (ut+st)/1000);
}

/* real time does not work on barr... (sunos/sparc) */
