Annotation of OpenXM_contrib2/asir2000/builtin/time.c, Revision 1.1
1.1 ! noro 1: /* $OpenXM: OpenXM/src/asir99/builtin/time.c,v 1.1.1.1 1999/11/10 08:12:26 noro Exp $ */
! 2: #include "ca.h"
! 3: #include "parse.h"
! 4:
! 5: void Ptime(), Pcputime(), Pcurrenttime(), Ptstart(), Ptstop();
! 6:
! 7: struct ftab time_tab[] = {
! 8: {"time",Ptime,0},
! 9: {"cputime",Pcputime,1},
! 10: {"currenttime",Pcurrenttime,0},
! 11: {"tstart",Ptstart,0},
! 12: {"tstop",Ptstop,0},
! 13: {0,0,0},
! 14: };
! 15:
! 16: static struct oEGT egt0;
! 17: static double r0;
! 18: double get_rtime(), get_current_time();
! 19:
! 20: void Pcurrenttime(rp)
! 21: Q *rp;
! 22: {
! 23: int t;
! 24:
! 25: t = (int)get_current_time(); STOQ(t,*rp);
! 26: }
! 27:
! 28: void Ptstart(rp)
! 29: pointer *rp;
! 30: {
! 31: get_eg(&egt0); r0 = get_rtime(); *rp = 0;
! 32: }
! 33:
! 34: void Ptstop(rp)
! 35: pointer *rp;
! 36: {
! 37: struct oEGT egt1;
! 38:
! 39: get_eg(&egt1); printtime(&egt0,&egt1,get_rtime()-r0); *rp = 0;
! 40: }
! 41:
! 42: int prtime;
! 43:
! 44: void Pcputime(arg,rp)
! 45: NODE arg;
! 46: pointer *rp;
! 47: {
! 48: prtime = ARG0(arg) ? 1 : 0; *rp = 0;
! 49: }
! 50:
! 51: void Ptime(listp)
! 52: LIST *listp;
! 53: {
! 54: struct oEGT eg;
! 55: Real re,rg,rr;
! 56: NODE a,b,w,r;
! 57: Q words;
! 58: int t;
! 59: double rtime;
! 60: double get_rtime();
! 61:
! 62: rtime = get_rtime(); MKReal(rtime,rr);
! 63: t = get_allocwords(); STOQ(t,words);
! 64: get_eg(&eg); MKReal(eg.exectime,re); MKReal(eg.gctime,rg);
! 65: MKNODE(r,rr,0); MKNODE(w,words,r); MKNODE(a,rg,w); MKNODE(b,re,a);
! 66: MKLIST(*listp,b);
! 67: }
! 68:
! 69: void printtime(egt0,egt1,r)
! 70: struct oEGT *egt0,*egt1;
! 71: double r;
! 72: {
! 73: double e,g;
! 74:
! 75: e = egt1->exectime - egt0->exectime;
! 76: if ( e < 0 ) e = 0;
! 77: g = egt1->gctime - egt0->gctime;
! 78: if ( g < 0 ) g = 0;
! 79: if ( g )
! 80: fprintf(stderr,"%.4gsec + gc : %.4gsec(%.4gsec)\n",e,g,r);
! 81: else
! 82: fprintf(stderr,"%.4gsec(%.4gsec)\n",e,r);
! 83: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>