Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Timing function execution
- X-seq: zsh-users 27315
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Cc: Zach Riggle <zachriggle@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Timing function execution
- Date: Sat, 6 Nov 2021 11:35:46 -0700
- Archived-at: <https://zsh.org/users/27315>
- In-reply-to: <CAH+w=7aLZwYvN0_KOdf9=HcLBUtYzoHKjL4ck8tKCjau9qoduw@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAMP9c5=YX9v969sVNcVcpbb8R6e4EoyrAMpqpEDAnpSYQi9Sbw@mail.gmail.com> <CAH+w=7Z2jJqxSAa6sD_+jBEbDfHTfa_aMr_9WLfWG5T1OcCNFw@mail.gmail.com> <CAN=4vMrPTZ033Nm1GdSiTH7oA=TyS6PBOo7VpYtaaiYLoPBp7g@mail.gmail.com> <CAH+w=7aLZwYvN0_KOdf9=HcLBUtYzoHKjL4ck8tKCjau9qoduw@mail.gmail.com>
On Sat, Nov 6, 2021 at 11:17 AM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Nov 6, 2021 at 9:21 AM Roman Perepelitsa
> <roman.perepelitsa@xxxxxxxxx> wrote:
> >
> > Could "time" invoke getrusage(RUSAGE_THREAD) before and after and
> > print the difference?
>
> That's a possibility. It'd only work on a subset of OSs, I think.
Glancing through builtin.c, "times" (based on library times(3)) may be
the answer?
% times ; foo; times
0m0.00s 0m0.00s
0m0.00s 0m0.00s
hello
0m0.01s 0m0.00s
0m0.00s 0m0.00s
I had entirely forgotten the existence of that builtin. Also quite
useful for a function because it separates in-shell user/system time
(first line) from sub-process (second line).
Messages sorted by:
Reverse Date,
Date,
Thread,
Author