Skip to content

romkatv/zsh-prompt-benchmark

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 

Repository files navigation

zsh-prompt-benchmark

zsh-prompt-benchmark allows you to measure how long it takes for your zsh prompt to render. Roughly speaking, if you press and hold [ENTER], how many prompts will be printed per second?

Installation

Manually

git clone https://github.com/romkatv/zsh-prompt-benchmark.git ~/zsh-prompt-benchmark
echo 'source ~/zsh-prompt-benchmark/zsh-prompt-benchmark.plugin.zsh' >>! ~/.zshrc

With Oh My Zsh

Clone the repo.

git clone https://github.com/romkatv/zsh-prompt-benchmark.git "$ZSH_CUSTOM/plugins/zsh-prompt-benchmark"

Enable zsh-prompt-benchmark plugin in ~/.zshrc.

plugins=(
  ...
  zsh-prompt-benchmark
)

Usage

zsh-prompt-benchmark [duration [warmup [done]]]

Optional positional arguments:

  • duration -- Benchmark for this many seconds. Default is 2.
  • warmup -- Sleep for this many seconds before benchmarking to fill the keyboard input buffer. This mitigates the problem caused by slow key repeat rate (see below). Default is 8.
  • done -- Run this command (via eval) when done. Default is empty.

After calling zsh-prompt-benchmark in an interactive shell you need to press and hold [ENTER] until you see benchmark results. It'll take 10 seconds with default arguments.

Make sure your repeat key rate is high enough that your shell is unable to keep up. While not benchmarking, press and hold [ENTER]. If you see empty lines between prompts or if prompts keep being printed after you release [ENTER], your repeat key rate is sufficient. If it's not, you can artificially boost it by buffering keyboard input buffer. Your effective key repeat rate is multiplied by 1 + warmup / duration. With default settings this is 1 + 8 / 2 == 5.

Example output:

********************************************************************  
                      Prompt Benchmark Results                      
********************************************************************
Warmup duration      8s
Benchmark duration   2.003s
Benchmarked prompts  553
Time per prompt      3.62ms  <-- prompt latency (lower is better)
********************************************************************

Why

I wrote it while optimizing Powerlevel9k ZSH theme, which resulted in the much faster Powerlevel10k.

About

Measure how long it takes for your zsh prompt to render

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages