zsh-workers
 help / color / mirror / code / Atom feed
* Module fun – automatic compilation of sourced scripts, sourcing-profiling
@ 2018-08-24 22:02 Sebastian Gniazdowski
  0 siblings, 0 replies; only message in thread
From: Sebastian Gniazdowski @ 2018-08-24 22:02 UTC (permalink / raw)
  To: Zsh hackers list

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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2018-08-24 22:02 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-24 22:02 Module fun – automatic compilation of sourced scripts, sourcing-profiling Sebastian Gniazdowski

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).