static char *sccsid
= "@(#)sh.time.c 4.1 10/9/80";
* C Shell - routines handling process timing and niceing
* dotime is only called if it is truly a builtin function and not a
* prefix to another command
pvtimes(&vm0
, &vm1
, timedol
- time0
);
ptimes(timedol
- time0
, ×0
, ×dol
);
* donice is only called when it on the line by itself or with a +- value
} else if (*v
== 0 && any(cp
[0], "+-")) {
ptimes(utime
, stime
, etime
)
register time_t utime
, stime
, etime
;
printf(" %d%%\n", (int) (100 * (utime
+stime
) /
(60 * (etime
? etime
: 1))));
register struct vtimes
*vp
, *wp
;
vp
->vm_utime
+= wp
->vm_utime
;
vp
->vm_stime
+= wp
->vm_stime
;
vp
->vm_nswap
+= wp
->vm_nswap
;
vp
->vm_idsrss
+= wp
->vm_idsrss
;
vp
->vm_ixrss
+= wp
->vm_ixrss
;
if (vp
->vm_maxrss
< wp
->vm_maxrss
)
vp
->vm_maxrss
= wp
->vm_maxrss
;
vp
->vm_majflt
+= wp
->vm_majflt
;
vp
->vm_minflt
+= wp
->vm_minflt
;
vp
->vm_inblk
+= wp
->vm_inblk
;
vp
->vm_oublk
+= wp
->vm_oublk
;
register struct vtimes
*v0
, *v1
;
(v1
->vm_utime
-v0
->vm_utime
)+(v1
->vm_stime
-v0
->vm_stime
);
register struct varent
*vp
= adrof("time");
cp
= "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww";
if (vp
&& vp
->vec
[0] && vp
->vec
[1])
else if (cp
[1]) switch(*++cp
) {
p60ths(v1
->vm_utime
- v0
->vm_utime
);
p60ths(v1
->vm_stime
- v0
->vm_stime
);
printf("%d%%", (int) ((100 * t
) / (60 * (sec
? sec
: 1))));
i
= v1
->vm_nswap
- v0
->vm_nswap
;
printf("%d", t
== 0 ? 0 : (v1
->vm_ixrss
-v0
->vm_ixrss
)/(2*t
));
printf("%d", t
== 0 ? 0 : (v1
->vm_idsrss
-v0
->vm_idsrss
)/(2*t
));
printf("%d", t
== 0 ? 0 : ((v1
->vm_ixrss
+v1
->vm_idsrss
) -
(v0
->vm_ixrss
+v0
->vm_idsrss
))/(2*t
));
printf("%d", v1
->vm_maxrss
/2);
printf("%d", v1
->vm_majflt
-v0
->vm_majflt
);
printf("%d", v1
->vm_minflt
-v0
->vm_minflt
);
printf("%d", v1
->vm_inblk
-v0
->vm_inblk
);
printf("%d", v1
->vm_oublk
-v0
->vm_oublk
);