Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Bug: time doesn't work on builtins
- X-seq: zsh-workers 53070
- From: Jun T <takimoto-j@xxxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Bug: time doesn't work on builtins
- Date: Fri, 6 Sep 2024 18:52:17 +0900
- Archived-at: <https://zsh.org/workers/53070>
- In-reply-to: <CAH+w=7aKEm0t37Df9kS0KEYXrp607zX+1cV3xtAJ9bbjfXgXsw@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <CAA=-s3w0wsH7xkS58JS0AbGdOoihYxq+cKEpVomFU_f1_w-ynQ@mail.gmail.com> <CAH+w=7a3BuQnPMa5YEy8n8ZNSNNoYNKLL9Aki5iCSPKbTyn5eQ@mail.gmail.com> <CAA=-s3z3YMho0a4A3H4h3o75oY1fR36w2zz83zQKjyPi3mSTpQ@mail.gmail.com> <CAH+w=7ZZ3frU9OjpkOmHzvL6Ws0YQPE=_JK+izmRR+gEcvSsDg@mail.gmail.com> <CAH+w=7ZpU-QCFAfPYvBFQvUnfekV35c3B_j7eoWvo8MokJ0Ncw@mail.gmail.com> <20C9A9EE-49A5-4A58-AA00-136A5D221331@kba.biglobe.ne.jp> <CAH+w=7aKEm0t37Df9kS0KEYXrp607zX+1cV3xtAJ9bbjfXgXsw@mail.gmail.com>
> 2024/09/06 9:10, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Wed, Sep 4, 2024 at 7:33 AM Jun. T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>>
>> The followings still give no time statistics:
>>
>> % time x=1
>> % time x=$(date)
>
> (Hand-fuzzed patch follows)
The patch works for the above two cases, but I've fond there
are still more problems...
[1] In the patch file "time-builtin.txt":
@@ -4377,6 +4384,8 @@ execcmd_exec(Estate state, Execcmd_params eparams,
errflag |= ERRFLAG_ERROR;
}
}
+ if (is_cursh && (how & Z_TIMED))
+ shelltime(&shti, is_builtin ? NULL : &chti, &then, 1);
Due to "is_builtin ? NULL : &chti", child time is not reported for
the cases such as
% time eval 'external command'
% time . ./script # script runs external command
I think it's better to pass &chti always.
[2] Time spent in prefork() is not included in the statistics.
% time echo $(x=0;for ((i=0; i<=100000; ++i)); do ((x+=i)); done; echo $x) 5000050000
shell 0.00s user 0.00s system 100% cpu 0.000 total
% time cat <(time-consuming-command) # cat is not builtin
(the problem existed before applying "time-builtin.txt")
% time echo $(external command)
Even if the problem [1] is fixed (by always passing &chti)
the time reported would not include the time used for
the 'external command'.
Not sure this can be fixed easily.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author