From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by werple.net.au (8.7/8.7.1) with ESMTP id WAA16266 for ; Wed, 6 Dec 1995 22:14:13 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id FAA06704; Wed, 6 Dec 1995 05:46:29 -0500 (EST) Resent-Date: Wed, 6 Dec 1995 05:46:29 -0500 (EST) Message-Id: <9512061045.AA24791@sgi.ifh.de> To: zsh-workers@math.gatech.edu (Zsh hackers list) Subject: timing more builtins Date: Wed, 06 Dec 1995 11:45:48 +0100 From: Peter Stephenson Resent-Message-ID: <"ONzkU3.0.ge1.4INnm"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/673 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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 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.