You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
jankeromnes
changed the title
Optimize ~/.bashrc.d/* loading time to make new terminals load faster
Optimize ~/.bashrc.d/* loading time to make new Gitpod terminals load faster
Apr 7, 2021
jankeromnes
changed the title
Optimize ~/.bashrc.d/* loading time to make new Gitpod terminals load faster
Optimize ~/.bashrc.d/* loading time to make new terminals load faster
Apr 7, 2021
Hi @jankeromnes! I could load everything in $HOME/.bashrc.d within just 0.001s with source $HOME/.bashrc.d/*. While this takes lot more cpu cycles and invocations of source command over the unnecessary for loop with ls, thus making it kinda slower 😓
Here are some logs 😄
gitpod /workspace/workspace-images $ time (for i in$(ls $HOME/.bashrc.d/*);dosource$i; done)
real 0m0.197s
user 0m0.151s
sys 0m0.083s
gitpod /workspace/workspace-images $ time (source $HOME/.bashrc.d/*)
real 0m0.001s
user 0m0.000s
sys 0m0.001s
gitpod /workspace/workspace-images $ time (source $HOME/.bashrc.d/*)
real 0m0.001s
user 0m0.000s
sys 0m0.001s
gitpod /workspace/workspace-images $ time (for i in$(ls $HOME/.bashrc.d/*);dosource$i; done)
real 0m0.239s
user 0m0.175s
sys 0m0.061s
gitpod /workspace/workspace-images $ time (for i in$(ls $HOME/.bashrc.d/*);dosource$i; done)
real 0m0.209s
user 0m0.151s
sys 0m0.096s
gitpod /workspace/workspace-images $
Edit: Well nope, sorry, my bad. source only takes one filename at a time, missed that point.
I added a few
date -Ins
into a~/.bashrc
on Gitpod, and found that loading all$HOME/.bashrc.d/*
scripts:workspace-images/base/Dockerfile
Line 54 in baa144a
... can take 313ms (sample size = 1)
Adding a few more
date -Ins
showed me that the longest-running$HOME/.bashrc.d/*
scripts could be:workspace-images/full/Dockerfile
Lines 158 to 160 in baa144a
... 109ms (sample size = 1)
workspace-images/full/Dockerfile
Line 188 in baa144a
... 116ms (sample size = 1)
The text was updated successfully, but these errors were encountered: