From: Sebastian Gniazdowski <psprint@zdharma.org>
To: zsh-users@zsh.org
Subject: Why sourcing a file is not faster than doing a loop with eval, zle -N
Date: Sat, 17 Jun 2017 13:34:00 +0200 [thread overview]
Message-ID: <etPan.594513a8.516100cd.10b2e@zdharma.org> (raw)
Hello,
I've tried to optimize my fast-syntax-highlighting. The idea is simple, instead of a loop:
for cur_widget in $widgets_to_bind; do
case $widgets[$cur_widget] in
...
builtin) eval "_zsh_highlight_widget_${(q)prefix}-${(q)cur_widget}() { _call_widget .${(q)cur_widget} -- \"\$@\" }"
zle -N $cur_widget _zsh_highlight_widget_$prefix-$cur_widget;;
...
...
I do, in the same loop:
...
print -r "zle -N" "$prefix-$cur_widget" "${widgets[$cur_widget]#*:}" >>| ~/.fsh_cache
...
and so on, to then only detect ~/.fsh_cache, and source it, skipping the loop. Times of "zsh -i -c exit" are:
- normal FSH: 0.3968 sec on average
- cache-feature FSH: 0.4329 sec on average
- zcompiled cache: 0.3831 sec on average
So, only after compiling ~/.fsh_cache, I get slightly better time, normally it is ~30 ms slower. I would expect this to be always and more faster. Why it is not?
I now suspect that maybe there's more parsing – loop doesn't have 554 lines like ~/.fsh_cache, and is parsed quickier.
Test data: https://github.com/zdharma/hacking-private/tree/master/FSH
--
Sebastian Gniazdowski
psprint /at/ zdharma.org
next reply other threads:[~2017-06-17 11:34 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-17 11:34 Sebastian Gniazdowski [this message]
[not found] ` <CAH+w=7bVXtubcdwvEBC9isE32683dUipAUS=vrAkgO5pp2bkkw@mail.gmail.com>
[not found] ` <CAH+w=7afTi=1bfLBCmq8-vB-rLWDtEkAtk8gCCna3-mQwZ1-Ow@mail.gmail.com>
2017-06-17 14:05 ` Bart Schaefer
[not found] ` <etPan.594538f9.2ea629d6.10b2e@AirmailxGenerated.am>
2017-06-17 14:56 ` Sebastian Gniazdowski
2017-06-17 15:44 ` Sebastian Gniazdowski
2017-06-17 16:39 ` Bart Schaefer
2017-06-17 17:25 ` Sebastian Gniazdowski
[not found] <etPan.594513a8.516100cd.10b2e__10513.1716504276$1497699329$gmane$org@zdharma.org>
2017-06-19 12:24 ` Stephane Chazelas
2017-06-19 15:31 ` Bart Schaefer
[not found] ` <170619083116.ZM17323__41722.0601499595$1497886320$gmane$org@torch.brasslantern.com>
2017-06-19 16:16 ` Stephane Chazelas
2017-06-19 19:14 ` 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=etPan.594513a8.516100cd.10b2e@zdharma.org \
--to=psprint@zdharma.org \
--cc=zsh-users@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).