Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: bug with for and time
- X-seq: zsh-workers 20460
- From: "Matthias B." <msbREMOVE-THIS@xxxxxxxxxxxxxxx>
- Subject: Re: bug with for and time
- Date: Wed, 6 Oct 2004 13:48:18 +0200
- Cc: zsh-workers@xxxxxxxxxx
- In-reply-to: <20041005181820.GC30419@xxxxxxxxxxxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <41616CDC.8020701@xxxxxxxxxxxxxxxx> <200410041610.i94GAl92005952@xxxxxxxxxxxxxx> <20041005113848.6f3715bd@xxxxxxxxxxxxxxxxxxxxx> <20041005181820.GC30419@xxxxxxxxxxxxxxxx>
On Tue, 5 Oct 2004 13:18:20 -0500 Dan Nelson <dnelson@xxxxxxxxxxxxxxx>
wrote:
> In the last episode (Oct 05), Matthias B. said:
> > On Mon, 04 Oct 2004 17:10:47 +0100 Peter Stephenson <pws@xxxxxxx>
> > wrote:
> > > Nathan Sidwell wrote:
> > > > Zsh 4.0.4 appears to lose the time command in the following,
> > > >
> > > > nathan@garibaldi:363>for i in 1 2 ; time echo
> > > >
> > > > but, place the command in a subshell, and it works.
> > >
> > > Yes, that's always been an annoying limitation: "time" works by
> > > gettings system information about subprocesses, and there isn't one
> > > in this case.
> >
> > Then how does bash do it? bash can time builtins just fine.
>
> It probably calls getrusage(RUSAGE_SELF) before and after whatever
> you're timing, then prints the deltas.
Then maybe zsh should do that, too. Right now, zsh's time function doesn't
work very well. Look at this:
/home/msb> TIMEFMT=$'real\t%*Es\nuser\t%*Us\nsys \t%*Ss\ncpu \t%P'
/home/msb> time /bin/echo foo
foo
real 0.000s
user 0.000s
sys 0.010s
cpu 8695%
/home/msb> time /bin/echo foo
foo
real 0.006s
user 0.000s
sys 0.000s
cpu 0%
/home/msb> time /bin/echo foo
foo
real 0.000s
user 0.010s
sys 0.000s
cpu 8928%
The numbers don't add up properly. I've never seen something like this
with bash.
MSB
--
Happiness through ignorance!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author