Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Module fun – automatic compilation of sourced scripts, sourcing-profiling



Hello,
just sharing that I've cooked up a module which:
1. Overloads bin_dot to implement: automatic compiling (i.e. calling
of bin_zcompile) of sourced scripts with use of already existing two
stat() calls (no new ones). This is a nice feature, because plugins
not-rarely use many small helper scripts and it's really hard to track
this with some ~/compile-all.zsh

2. gettimeofday() calling at beginning and end of init.c:source() (why
not bin_dot, I now think), storing difference in a hash under
progressing index, displaying list of all sourced scripts with
duration in milliseconds – a basic but capable profiling tool. Also,
no script can pass-through that place in code, and the resulting list
of all sourced scripts can be surprising.

The methodology is somewhat distinct, because when I e.g. wanted to
use 2 already existing stat() calls, I've had to keep copying
bin_dot() descendants until I've reached the needed function. So user
of Zsh 5.1 will be using bin_dot and related code in version 5.5.1
actually.

Source code of the module:

https://github.com/zdharma/zplugin/tree/master/zmodules/Src/zdharma

There's an install script, it clones to ~/.zplugin/mod-bin and builds
the module, displays what to add to ~/.zshrc to load it:

sh -c "$(curl -fsSL
https://raw.githubusercontent.com/zdharma/zplugin/master/doc/mod-install.sh)"

-- 
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org



Messages sorted by: Reverse Date, Date, Thread, Author