源码编译
./configure --prefix=$HOME/.usr/local/ --without-x --enable-gui=no
测试版本
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 7 2025 14:30:02)
Included patches: 1-993
测试脚本
#!/usr/bin/env bash
cnt=0
> startup.txt
while true
do
vim --not-a-term --startuptime startup.txt -c q
cnt=$((cnt+1))
if [[ "$cnt" -gt "$1" ]];then
break
fi
done
total=$(awk '/editing files in windows/ {sum += $1} END {print sum}' startup.txt)
printf "%.3f ms\n" $(echo "$total/$cnt" | bc -l)
声明
个人优化方面基于vim9script,且需要牺牲一定实用性,不过也有所收获
优化之前
- 使用测试脚本测试1000次
sh test.sh 1000
21.504 ms
- 最后一次启动信息
000.004 000.004: --- VIM STARTING ---
000.076 000.072: Allocated generic buffers
000.148 000.072: locale set
000.151 000.003: window checked
000.491 000.340: inits 1
000.510 000.019: parsing arguments
000.511 000.001: expanding arguments
000.536 000.025: shell init
000.769 000.233: Termcap init
000.778 000.009: inits 2
000.889 000.111: init highlight
009.720 008.646 008.646: sourcing /home/rothwell/.usr/local/share/vim/vim91/filetype.vim
009.910 000.059 000.059: sourcing /home/rothwell/.usr/local/share/vim/vim91/ftplugin.vim
009.983 000.034 000.034: sourcing /home/rothwell/.usr/local/share/vim/vim91/indent.vim
010.168 009.132 000.393: sourcing /home/rothwell/.vim/vimrc/option.vim
012.368 000.755 000.755: sourcing /home/rothwell/.usr/local/share/vim/vim91/colors/lists/default.vim
012.858 000.409 000.409: sourcing /home/rothwell/.vim/pack/vimpack/opt/color.vim/colors/gruvbox.vim
012.938 001.426 000.262: sourcing /home/rothwell/.usr/local/share/vim/vim91/syntax/synload.vim
013.013 001.600 000.174: sourcing /home/rothwell/.usr/local/share/vim/vim91/syntax/syntax.vim
013.174 000.078 000.078: sourcing /home/rothwell/.usr/local/share/vim/vim91/ftplugin/man.vim
013.486 003.294 001.616: sourcing /home/rothwell/.vim/vimrc/plugin.vim
013.861 000.354 000.354: sourcing /home/rothwell/.vim/vimrc/misc.vim
014.531 000.645 000.645: sourcing /home/rothwell/.vim/vimrc/keymap.vim
014.536 013.537 000.112: sourcing $HOME/.vimrc
014.538 000.112: sourcing vimrc file(s)
014.820 000.147 000.147: sourcing /home/rothwell/.vim/pack/vimpack/opt/matchparen.vim/plugin/matchparen.vim
014.954 000.072 000.072: sourcing /home/rothwell/.vim/pack/vimpack/opt/fzy.vim/plugin/fzf.vim
015.049 000.045 000.045: sourcing /home/rothwell/.vim/pack/vimpack/opt/floaterm.vim/plugin/floaterm.vim
015.152 000.056 000.056: sourcing /home/rothwell/.vim/pack/vimpack/opt/git.vim/plugin/git.vim
015.387 000.165 000.165: sourcing /home/rothwell/.vim/pack/vimpack/opt/sign.vim/plugin/sign.vim
015.562 000.122 000.122: sourcing /home/rothwell/.vim/pack/vimpack/opt/mark.vim/plugin/mark.vim
015.676 000.057 000.057: sourcing /home/rothwell/.vim/pack/vimpack/opt/j.vim/plugin/j.vim
015.883 000.141 000.141: sourcing /home/rothwell/.vim/pack/vimpack/opt/auto-pairs.vim/plugin/auto-pairs.vim
015.987 000.043 000.043: sourcing /home/rothwell/.vim/pack/vimpack/opt/line.vim/plugin/line.vim
016.319 000.077 000.077: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/getscriptPlugin.vim
016.538 000.200 000.200: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/gzip.vim
016.789 000.234 000.234: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/logiPat.vim
016.847 000.038 000.038: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/manpager.vim
017.217 000.355 000.355: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/matchparen.vim
017.827 000.589 000.589: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/netrwPlugin.vim
017.875 000.013 000.013: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/rrhelper.vim
017.919 000.024 000.024: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/spellfile.vim
018.116 000.179 000.179: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/tarPlugin.vim
018.337 000.186 000.186: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/tohtml.vim
018.396 000.027 000.027: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/tutor.vim
018.685 000.268 000.268: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/vimballPlugin.vim
018.949 000.216 000.216: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/zipPlugin.vim
019.442 000.388 000.388: sourcing /home/rothwell/.usr/local/share/vim/vim91/pack/dist/opt/matchit/plugin/matchit.vim
019.449 001.269: loading plugins
019.523 000.074: loading packages
019.546 000.023: loading after plugins
019.553 000.007: inits 3
019.997 000.444: reading viminfo
020.007 000.010: setting raw mode
020.063 000.056: start termcap
020.103 000.040: clearing screen
021.841 000.211 000.211: sourcing /home/rothwell/.vim/pack/vimpack/opt/mark.vim/autoload/mark.vim
021.957 001.643: opening buffers
021.982 000.025: BufEnter autocommands
021.984 000.002: editing files in windows
优化之后
- 使用测试脚本测试1000次
sh test.sh 1000
9.040 ms
- 最后一次启动信息
000.004 000.004: --- VIM STARTING ---
000.085 000.081: Allocated generic buffers
000.172 000.087: locale set
000.176 000.004: window checked
000.495 000.319: inits 1
000.530 000.035: parsing arguments
000.531 000.001: expanding arguments
000.562 000.031: shell init
000.941 000.379: Termcap init
000.953 000.012: inits 2
001.061 000.108: init highlight
001.599 000.313 000.313: sourcing /home/rothwell/.usr/local/share/vim/vim91/filetype.vim
001.715 000.067 000.067: sourcing /home/rothwell/.usr/local/share/vim/vim91/ftplugin.vim
001.786 000.032 000.032: sourcing /home/rothwell/.usr/local/share/vim/vim91/indent.vim
002.198 000.957 000.545: sourcing /home/rothwell/.vim/vimrc/option.vim
004.402 000.004 000.004: sourcing /home/rothwell/.usr/local/share/vim/vim91/colors/lists/default.vim
004.887 000.412 000.412: sourcing /home/rothwell/.vim/pack/vimpack/opt/color.vim/colors/gruvbox.vim
004.978 000.682 000.266: sourcing /home/rothwell/.usr/local/share/vim/vim91/syntax/synload.vim
005.077 000.894 000.212: sourcing /home/rothwell/.usr/local/share/vim/vim91/syntax/syntax.vim
005.243 000.083 000.083: sourcing /home/rothwell/.usr/local/share/vim/vim91/ftplugin/man.vim
005.552 003.297 002.320: sourcing /home/rothwell/.vim/vimrc/plugin.vim
005.654 000.078 000.078: sourcing /home/rothwell/.vim/vimrc/misc.vim
006.329 000.655 000.655: sourcing /home/rothwell/.vim/vimrc/keymap.vim
006.334 005.141 000.154: sourcing $HOME/.vimrc
006.336 000.134: sourcing vimrc file(s)
006.557 000.075 000.075: sourcing /home/rothwell/.vim/pack/vimpack/opt/matchparen.vim/plugin/matchparen.vim
006.689 000.072 000.072: sourcing /home/rothwell/.vim/pack/vimpack/opt/fzy.vim/plugin/fzf.vim
006.810 000.071 000.071: sourcing /home/rothwell/.vim/pack/vimpack/opt/floaterm.vim/plugin/floaterm.vim
006.922 000.060 000.060: sourcing /home/rothwell/.vim/pack/vimpack/opt/git.vim/plugin/git.vim
007.105 000.108 000.108: sourcing /home/rothwell/.vim/pack/vimpack/opt/sign.vim/plugin/sign.vim
007.251 000.077 000.077: sourcing /home/rothwell/.vim/pack/vimpack/opt/mark.vim/plugin/mark.vim
007.364 000.057 000.057: sourcing /home/rothwell/.vim/pack/vimpack/opt/j.vim/plugin/j.vim
007.582 000.139 000.139: sourcing /home/rothwell/.vim/pack/vimpack/opt/auto-pairs.vim/plugin/auto-pairs.vim
007.734 000.071 000.071: sourcing /home/rothwell/.vim/pack/vimpack/opt/line.vim/plugin/line.vim
008.292 000.453 000.453: sourcing /home/rothwell/.usr/local/share/vim/vim91/plugin/netrwPlugin.vim
008.868 000.447 000.447: sourcing /home/rothwell/.usr/local/share/vim/vim91/pack/dist/opt/matchit/plugin/matchit.vim
008.873 000.907: loading plugins
008.959 000.086: loading packages
008.991 000.032: loading after plugins
008.996 000.005: inits 3
009.472 000.476: reading viminfo
009.481 000.009: setting raw mode
009.502 000.021: start termcap
009.518 000.016: clearing screen
010.040 000.137 000.137: sourcing /home/rothwell/.vim/pack/vimpack/opt/mark.vim/autoload/mark.vim
010.124 000.469: opening buffers
010.146 000.022: BufEnter autocommands
010.147 000.001: editing files in windows
标签:plugin,vim,sourcing,rothwell,home,vim9script,小结,usr
From: https://www.cnblogs.com/rdwr/p/18657639