00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include "defs.h"
00022
00023
00024 #include <sys/times.h>
00025
00026 static struct tms tbuf1;
00027 static clock_t real1;
00028 static long clock_ticks;
00029
00030 void timestart(void)
00031 {
00032 ec_neg1( real1 = times(&tbuf1) )
00033
00034 ec_neg1( clock_ticks = sysconf(_SC_CLK_TCK) )
00035 return;
00036
00037 EC_CLEANUP_BGN
00038 EC_FLUSH("timestart");
00039 EC_CLEANUP_END
00040 }
00041
00042 void timestop(char *msg)
00043 {
00044 struct tms tbuf2;
00045 clock_t real2;
00046
00047 ec_neg1( real2 = times(&tbuf2) )
00048 fprintf(stderr,"%s:\n\t\"Total (user/sys/real)\", %.2f, %.2f, %.2f\n"
00049 "\t\"Child (user/sys)\", %.2f, %.2f\n", msg,
00050 ((double)(tbuf2.tms_utime + tbuf2.tms_cutime) -
00051 (tbuf1.tms_utime + tbuf1.tms_cutime)) / clock_ticks,
00052 ((double)(tbuf2.tms_stime + tbuf2.tms_cstime) -
00053 (tbuf1.tms_stime + tbuf1.tms_cstime)) / clock_ticks,
00054 (double)(real2 - real1) / clock_ticks,
00055 (double)(tbuf2.tms_cutime - tbuf1.tms_cutime) / clock_ticks,
00056 (double)(tbuf2.tms_cstime - tbuf1.tms_cstime) / clock_ticks);
00057 return;
00058
00059 EC_CLEANUP_BGN
00060 EC_FLUSH("timestop");
00061 EC_CLEANUP_END
00062 }
00063