Skip to content

Commit

Permalink
Updating README.md file with shell startup performance data (#20)
Browse files Browse the repository at this point in the history
* Removing duplicated check for interactive shell in .zshrc

* Updating README.md file with shell startup performance data
  • Loading branch information
hpedrorodrigues authored Dec 7, 2020
1 parent 9609b6e commit 1d00a78
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 44 deletions.
31 changes: 15 additions & 16 deletions .file/os/linux/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,23 @@ if [ -f "${HOME}/.zgen/zgen.zsh" ]; then

zgen save
fi
fi

# Force regenerate the .zcompdump file with the sphynx completions
# if they were not included before
if ! grep -q sx "${HOME}/.zcompdump"; then
if hash sx &>/dev/null; then
# Regenerating .zcompdump file when sphynx completions were not loaded
if ! grep -q 'sx' "${HOME}/.zcompdump"; then
autoload -U compinit && compinit
fi
fi

# Load the tmux "hack" session on zsh startup
# Notes:
# - not loading tmux in sphynx benchmarks because it's not important for it
# - not loading tmux if a screen session is currently active
# - loading the tmux session only when using Alacritty
if [[ $- == *i* ]] \
&& hash sx &>/dev/null \
&& [ -z "${SX_SHELL_BENCHMARK}" ] \
&& [ -z "${STY}" ] \
&& [ -z "${TMUX}" ] \
&& [ -n "${ALACRITTY_LOG}" ]; then
sx terminal tmux force-attach hack
# Load the tmux "hack" session on zsh startup
# Notes:
# - not loading tmux in sphynx benchmarks because it's not important for it
# - not loading tmux if a screen session is currently active
# - loading the tmux session only when using Alacritty
if [ -z "${SX_SHELL_BENCHMARK}" ] \
&& [ -z "${STY}" ] \
&& [ -z "${TMUX}" ] \
&& [ -n "${ALACRITTY_LOG}" ]; then
sx terminal tmux force-attach hack
fi
fi
31 changes: 15 additions & 16 deletions .file/os/osx/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,23 @@ if [ -f "${HOME}/.zgen/zgen.zsh" ]; then

zgen save
fi
fi

# Force regenerate the .zcompdump file with the sphynx completions
# if they were not included before
if ! grep -q sx "${HOME}/.zcompdump"; then
if hash sx &>/dev/null; then
# Regenerating .zcompdump file when sphynx completions were not loaded
if ! grep -q 'sx' "${HOME}/.zcompdump"; then
autoload -U compinit && compinit
fi
fi

# Load the tmux "hack" session on zsh startup
# Notes:
# - not loading tmux in sphynx benchmarks because it's not important for it
# - not loading tmux if a screen session is currently active
# - loading the tmux session only when using Alacritty
if [[ $- == *i* ]] \
&& hash sx &>/dev/null \
&& [ -z "${SX_SHELL_BENCHMARK}" ] \
&& [ -z "${STY}" ] \
&& [ -z "${TMUX}" ] \
&& [ -n "${ALACRITTY_LOG}" ]; then
sx terminal tmux force-attach hack
# Load the tmux "hack" session on zsh startup
# Notes:
# - not loading tmux in sphynx benchmarks because it's not important for it
# - not loading tmux if a screen session is currently active
# - loading the tmux session only when using Alacritty
if [ -z "${SX_SHELL_BENCHMARK}" ] \
&& [ -z "${STY}" ] \
&& [ -z "${TMUX}" ] \
&& [ -n "${ALACRITTY_LOG}" ]; then
sx terminal tmux force-attach hack
fi
fi
60 changes: 48 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,22 +49,58 @@ files! Beware!

**zsh**
```bash
♪ repeat 5 { /usr/bin/time zsh -i -c exit }
0.10 real 0.05 user 0.04 sys
0.11 real 0.06 user 0.04 sys
0.11 real 0.06 user 0.04 sys
0.11 real 0.06 user 0.04 sys
0.12 real 0.06 user 0.05 sys
♪ sx shell benchmark zsh
> Hyperfine

Benchmark #1: zsh -i -c exit
Time (mean ± σ): 130.6 ms ± 2.4 ms [User: 70.4 ms, System: 52.5 ms]
Range (min … max): 126.4 ms … 136.7 ms 21 runs

> Bench

benchmarking zsh -i -c exit
time 128.7 ms (125.4 ms .. 131.6 ms)
0.999 R² (0.998 R² .. 1.000 R²)
mean 126.2 ms (125.3 ms .. 127.6 ms)
std dev 1.628 ms (964.9 μs .. 2.354 ms)
variance introduced by outliers: 11% (moderately inflated)

> Time

/usr/bin/time zsh -i -c exit (5x)
0.14 real 0.07 user 0.06 sys
0.13 real 0.07 user 0.05 sys
0.13 real 0.07 user 0.05 sys
0.14 real 0.07 user 0.05 sys
0.16 real 0.08 user 0.07 sys
```

**bash**
```bash
♪ repeat 5 { /usr/bin/time bash -i -c exit }
0.10 real 0.06 user 0.06 sys
0.10 real 0.06 user 0.05 sys
0.09 real 0.06 user 0.05 sys
0.09 real 0.06 user 0.05 sys
0.10 real 0.06 user 0.05 sys
♪ sx shell benchmark bash
> Hyperfine

Benchmark #1: bash -i -c exit
Time (mean ± σ): 111.5 ms ± 2.7 ms [User: 71.1 ms, System: 63.4 ms]
Range (min … max): 107.7 ms … 117.6 ms 24 runs

> Bench

benchmarking bash -i -c exit
time 104.7 ms (97.34 ms .. 112.0 ms)
0.989 R² (0.962 R² .. 1.000 R²)
mean 103.8 ms (100.4 ms .. 106.9 ms)
std dev 5.138 ms (3.102 ms .. 7.333 ms)
variance introduced by outliers: 10% (moderately inflated)

> Time

/usr/bin/time bash -i -c exit (5x)
0.16 real 0.08 user 0.09 sys
0.11 real 0.07 user 0.06 sys
0.11 real 0.07 user 0.06 sys
0.11 real 0.07 user 0.07 sys
0.11 real 0.07 user 0.06 sys
```

**Inspiration**:
Expand Down

0 comments on commit 1d00a78

Please sign in to comment.