Comments (3)
I've been shaving microseconds the last couple of days. And I have found that replacing zgen with a shim function saves time:
# Load zgen only if a user types a zgen command
zgen () {
if [[ ! -s ${ZDOTDIR:-${HOME}}/.zgen/zgen.zsh ]]; then
git clone --recursive https://github.com/tarjoilija/zgen.git ${ZDOTDIR:-${HOME}}/.zgen
fi
source ${ZDOTDIR:-${HOME}}/.zgen/zgen.zsh
zgen "$@"
}
Then in your init check script, you can use:
# check if there's no init script
if [[ ! -s ${ZDOTDIR:-${HOME}}/.zgen/init.zsh ]]; then
echo "Creating a zgen save"
else
source ${ZDOTDIR:-${HOME}}/.zgen/init.zsh
fi
And maybe you want to do:
zcompile ${ZDOTDIR:-${HOME}}/.zgen/init.zsh
After generating the init script. Right after zgen save
.
This gives me:
Using zgen
repeat 10 {time zsh -i -c exit}
zsh -i -c exit 0.09s user 0.03s system 98% cpu 0.124 total
zsh -i -c exit 0.09s user 0.03s system 97% cpu 0.118 total
zsh -i -c exit 0.09s user 0.03s system 97% cpu 0.126 total
zsh -i -c exit 0.08s user 0.03s system 98% cpu 0.110 total
zsh -i -c exit 0.08s user 0.03s system 98% cpu 0.117 total
zsh -i -c exit 0.08s user 0.03s system 98% cpu 0.117 total
zsh -i -c exit 0.10s user 0.03s system 98% cpu 0.130 total
zsh -i -c exit 0.09s user 0.03s system 98% cpu 0.122 total
zsh -i -c exit 0.08s user 0.03s system 98% cpu 0.111 total
zsh -i -c exit 0.08s user 0.03s system 98% cpu 0.111 total
Using shim and direct test against and sourcing of init.zsh
repeat 10 {time zsh -i -c exit}
zsh -i -c exit 0.05s user 0.02s system 96% cpu 0.068 total
zsh -i -c exit 0.05s user 0.02s system 97% cpu 0.073 total
zsh -i -c exit 0.05s user 0.02s system 95% cpu 0.072 total
zsh -i -c exit 0.05s user 0.02s system 96% cpu 0.068 total
zsh -i -c exit 0.05s user 0.02s system 96% cpu 0.072 total
zsh -i -c exit 0.05s user 0.02s system 96% cpu 0.071 total
zsh -i -c exit 0.05s user 0.02s system 97% cpu 0.070 total
zsh -i -c exit 0.05s user 0.02s system 96% cpu 0.076 total
zsh -i -c exit 0.05s user 0.02s system 97% cpu 0.068 total
zsh -i -c exit 0.05s user 0.02s system 97% cpu 0.073 total
Does something like that improve loading times for you?
from zgen.
Ironically, not saving the configuration is faster than saving it.
With saving
➜ for i in {1..5}; do /usr/bin/time zsh -i -c exit; done
1.62user 0.28system 0:01.86elapsed 102%CPU (0avgtext+0avgdata 36988maxresident)k
0inputs+48outputs (0major+111549minor)pagefaults 0swaps
1.59user 0.33system 0:01.86elapsed 103%CPU (0avgtext+0avgdata 36936maxresident)k
0inputs+48outputs (0major+111176minor)pagefaults 0swaps
1.59user 0.33system 0:01.87elapsed 102%CPU (0avgtext+0avgdata 37436maxresident)k
0inputs+48outputs (0major+111984minor)pagefaults 0swaps
1.59user 0.32system 0:01.84elapsed 103%CPU (0avgtext+0avgdata 37096maxresident)k
0inputs+48outputs (0major+111236minor)pagefaults 0swaps
1.62user 0.30system 0:01.87elapsed 103%CPU (0avgtext+0avgdata 36984maxresident)k
0inputs+48outputs (0major+111390minor)pagefaults 0swaps
Without saving:
➜ for i in {1..5}; do /usr/bin/time zsh -i -c exit; done
1.45user 0.29system 0:01.75elapsed 99%CPU (0avgtext+0avgdata 33328maxresident)k
0inputs+64outputs (0major+81763minor)pagefaults 0swaps
1.35user 0.25system 0:01.60elapsed 100%CPU (0avgtext+0avgdata 33368maxresident)k
0inputs+64outputs (0major+81667minor)pagefaults 0swaps
1.33user 0.27system 0:01.60elapsed 100%CPU (0avgtext+0avgdata 33280maxresident)k
0inputs+64outputs (0major+81729minor)pagefaults 0swaps
1.39user 0.30system 0:01.69elapsed 100%CPU (0avgtext+0avgdata 33340maxresident)k
0inputs+64outputs (0major+81740minor)pagefaults 0swaps
1.36user 0.27system 0:01.62elapsed 100%CPU (0avgtext+0avgdata 33408maxresident)k
0inputs+64outputs (0major+81695minor)pagefaults 0swaps
🤕
I could do with more time saving, but this is a start
from zgen.
I've created a maintained fork of zgen - dubbed zgenom - which fixes some bugs as well as introducing new features like lazy loading and compiling the source files which should improve this issue.
from zgen.
Related Issues (20)
- Support Zsh plugin standard? HOT 2
- Why is $fpath extended after sourcing plugins? HOT 2
- Profiling plugin loads HOT 1
- zsh-vim-mode does not work
- zgen-update fails after latest update HOT 3
- Errors occurred when using oh-my-zsh and prezto together HOT 6
- Is there any sense that zgen loads some default plugins for prezto? HOT 1
- Adding environment variables to specific loaded modules
- Default loading of prezto modules breaks prezto docs
- selfupdate is broken
- Add ability to run makefile in plugin directory after installing.
- this a faster oh-my-zsh plugin manager than zsh itself?
- zplug equivalent HOT 1
- is zgen dead? HOT 9
- Set :prezto:load:pmodule-dirs
- Can't source zgen HOT 1
- Request: new load syntax for _not_ cloning submodules HOT 1
- How to load https://github.com/zimfw/archive? HOT 1
- Remove zgen and revert HOT 4
- bashcompinit
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zgen.