Skip to content

Instantly share code, notes, and snippets.

@shellheim
Created July 11, 2026 14:38
Show Gist options
  • Select an option

  • Save shellheim/f7f23bfc77c047e0dc66d40003543b4f to your computer and use it in GitHub Desktop.

Select an option

Save shellheim/f7f23bfc77c047e0dc66d40003543b4f to your computer and use it in GitHub Desktop.
Neovim Benchmark Script
#!/usr/bin/env bash
RUNS=${1:-10}
LOGFILE=$(mktemp)
TOTAL_TIME=0
RED_BOLD='\033[1;31m' # Bold and Red
RED='\033[0;31m' # Standard Red
NC='\033[0m' # No Color (reset)
for i in 1; do
# \r returns the cursor to the start of the line so it overwrites instead of stacking
printf "\rBenchmarking Neovim startup time over %d runs..." "$RUNS" "$i"
sleep 1
done
printf "\rBenchmarking Neovim startup time over %d runs... Go! \n" "$RUNS"
echo "------------------------------------------------"
for ((i = 1; i <= RUNS; i++)); do
nvim --headless --startuptime "$LOGFILE" -c "qa"
# Extract the first column (timestamp) from the "NVIM STARTED" line
RUN_TIME=$(awk '/NVIM STARTED/ {print $1}' "$LOGFILE" | tail -n 1)
if [[ -z "$RUN_TIME" ]]; then
echo "Error: Could not parse startup time from log."
rm -f "$LOGFILE"
exit 1
fi
printf "${RED_BOLD}Run %02d:${NC} %7s ms\n\n" "$i" "$RUN_TIME"
TOTAL_TIME=$(awk "BEGIN {print $TOTAL_TIME + $RUN_TIME}")
done
AVG_TIME=$(awk "BEGIN {printf \"%.2f\", $TOTAL_TIME / $RUNS}")
echo "------------------------------------------------"
printf "Average startup time: ${RED}%s ms${NC}\n" "${AVG_TIME}"
rm -f "$LOGFILE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment