From: Jun T <takimoto-j@kba.biglobe.ne.jp>
To: zsh-workers@zsh.org
Subject: Re: Bug: time doesn't work on builtins
Date: Fri, 6 Sep 2024 18:52:17 +0900 [thread overview]
Message-ID: <CEAB70F9-A50B-4A2E-90B8-A8017E921EA7@kba.biglobe.ne.jp> (raw)
In-Reply-To: <CAH+w=7aKEm0t37Df9kS0KEYXrp607zX+1cV3xtAJ9bbjfXgXsw@mail.gmail.com>
> 2024/09/06 9:10, Bart Schaefer <schaefer@brasslantern.com> wrote:
>
> On Wed, Sep 4, 2024 at 7:33 AM Jun. T <takimoto-j@kba.biglobe.ne.jp> 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.
next prev parent reply other threads:[~2024-09-06 9:52 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-15 13:15 Mark J. Reed
2024-08-15 18:52 ` Bart Schaefer
2024-08-15 22:08 ` Mark J. Reed
2024-08-16 19:20 ` Bart Schaefer
2024-09-04 0:27 ` Bart Schaefer
2024-09-04 14:32 ` Jun. T
2024-09-05 17:29 ` Jun. T
2024-09-05 23:37 ` Bart Schaefer
2024-09-06 9:41 ` Jun T
2024-09-06 0:10 ` Bart Schaefer
2024-09-06 9:52 ` Jun T [this message]
2024-09-06 19:13 ` Bart Schaefer
2024-09-14 2:10 ` PATCH: " Bart Schaefer
2024-09-20 7:46 ` Oliver Kiddle
2024-09-22 0:59 ` Bart Schaefer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CEAB70F9-A50B-4A2E-90B8-A8017E921EA7@kba.biglobe.ne.jp \
--to=takimoto-j@kba.biglobe.ne.jp \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).