Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Example / partial fix for printf with math expressions
- X-seq: zsh-workers 52600
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: Example / partial fix for printf with math expressions
- Date: Sun, 25 Feb 2024 06:54:00 +0000
- Archived-at: <https://zsh.org/workers/52600>
- In-reply-to: <20240224144041.7huny3lmihsrokdm@chazelas.org>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <CAH+w=7Z+vjX7sAgajLsQJw2KkZtyvaZvvJ+-=-7rMFH7p9+j7g@mail.gmail.com> <20240224144041.7huny3lmihsrokdm@chazelas.org>
2024-02-24 14:40:41 +0000, Stephane Chazelas:
[...]
> With the one below using curlen / len[argp-args]:
[...]
> + zlongval = (curarg) ? mathevali(metafy(curarg, curlen, META_HEAPDUP)) : 0;
[...]
That incur a performance penalty:
$ time zsh -c 'repeat 1000 printf %d 123_456+{1..10000}' > /dev/null
zsh -c 'repeat 1000 printf %d 123_456+{1..10000}' > /dev/null 6.07s user 0.46s system 99% cpu 6.544 total
$ time ./Src/zsh -c 'repeat 1000 printf %d 123_456+{1..10000}' > /dev/null
./Src/zsh -c 'repeat 1000 printf %d 123_456+{1..10000}' > /dev/null 9.97s user 0.62s system 99% cpu 10.602 total
The numbers end up being metafied (earlier), unmetafied by
printf, metafied again by printf here and that metafication
processed by the math handler I guess.
Maybe the performance could be *improved* instead if the
unmetafication could be skipped altogether in printf in those
cases?
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author