zsh-workers
 help / color / mirror / code / Atom feed
* timing more builtins
@ 1995-12-06 10:45 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 1995-12-06 10:45 UTC (permalink / raw)
  To: Zsh hackers list

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@ifh.de>       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.


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1995-12-06 11:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-12-06 10:45 timing more builtins Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).