From 1d00a78611d2632eac31d9260c907ecc56b8d55c Mon Sep 17 00:00:00 2001 From: Pedro Rodrigues Date: Mon, 7 Dec 2020 20:56:04 -0300 Subject: [PATCH] Updating README.md file with shell startup performance data (#20) * Removing duplicated check for interactive shell in .zshrc * Updating README.md file with shell startup performance data --- .file/os/linux/.zshrc | 31 +++++++++++----------- .file/os/osx/.zshrc | 31 +++++++++++----------- README.md | 60 ++++++++++++++++++++++++++++++++++--------- 3 files changed, 78 insertions(+), 44 deletions(-) diff --git a/.file/os/linux/.zshrc b/.file/os/linux/.zshrc index c1ac7b5f..11b2a294 100644 --- a/.file/os/linux/.zshrc +++ b/.file/os/linux/.zshrc @@ -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 diff --git a/.file/os/osx/.zshrc b/.file/os/osx/.zshrc index c1ac7b5f..11b2a294 100644 --- a/.file/os/osx/.zshrc +++ b/.file/os/osx/.zshrc @@ -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 diff --git a/README.md b/README.md index b1a597a7..a0620a17 100644 --- a/README.md +++ b/README.md @@ -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**: