Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
timing more builtins
- X-seq: zsh-workers 673
- From: Peter Stephenson <pws@xxxxxx>
- To: zsh-workers@xxxxxxxxxxxxxxx (Zsh hackers list)
- Subject: timing more builtins
- Date: Wed, 06 Dec 1995 11:45:48 +0100
There's a slight mistake in my patch for timing builtins: I used the
times for child processes instead of the times for the current shell
process. This fixes that.
Actually, it's not that trivial, since the current shell could be
running a structure which calls external processes; then, presumably,
you want to include the times spent in those subprocesses, and you
don't get it. In other words,
% time { do_some_heavy_processing }
and
% time do_some_heavy_processing
give very different results.
It could be fixed, but it would probably be a little messy: you need
to know whether the process being executed was started within the
structure being timed, or outside it, remember that in the process
structure, and get the signal handler to add the times if necessary.
I doubt if I'll bother doing this myself until the new timing code's
actually in use.
*** Src/exec.c.t2 Wed Dec 6 11:26:45 1995
--- Src/exec.c Wed Dec 6 11:27:37 1995
***************
*** 1628,1635 ****
if (curshproc) {
times(&shtms);
! curshproc->ti.st = shtms.tms_cstime - curshproc->ti.st;
! curshproc->ti.ut = shtms.tms_cutime - curshproc->ti.ut;
/* Status mustn't look like we've had a signal */
curshproc->status = lastval & 0x7f;
gettimeofday(&curshproc->endtime, &dummy_tz);
--- 1628,1635 ----
if (curshproc) {
times(&shtms);
! curshproc->ti.st = shtms.tms_stime - curshproc->ti.st;
! curshproc->ti.ut = shtms.tms_utime - curshproc->ti.ut;
/* Status mustn't look like we've had a signal */
curshproc->status = lastval & 0x7f;
gettimeofday(&curshproc->endtime, &dummy_tz);
*** Src/jobs.c.t2 Wed Dec 6 11:28:31 1995
--- Src/jobs.c Wed Dec 6 11:29:16 1995
***************
*** 432,441 ****
if (procarg && !(flags & ADDPROC_USE)) {
/* We're going to process this process elsewhere.
* We need the current shell times to subtract later on.
*/
times(&shtms);
! process->ti.st = shtms.tms_cstime;
! process->ti.ut = shtms.tms_cutime;
*procarg = process;
}
}
--- 432,442 ----
if (procarg && !(flags & ADDPROC_USE)) {
/* We're going to process this process elsewhere.
* We need the current shell times to subtract later on.
+ * N.B.: these do not include the times of any children.
*/
times(&shtms);
! process->ti.st = shtms.tms_stime;
! process->ti.ut = shtms.tms_utime;
*procarg = process;
}
}
--
Peter Stephenson <pws@xxxxxx> Tel: +49 33762 77366
WWW: http://www.ifh.de/~pws/ Fax: +49 33762 77330
Deutches Electronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author