首页 > 其他分享 >vim启动速度优化小结(基于vim9script)

vim启动速度优化小结(基于vim9script)

时间:2025-01-07 15:13:51浏览次数:1  
标签:plugin vim sourcing rothwell home vim9script 小结 usr

源码编译

./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

相关文章

  • Vim的使用方法
    Vim的使用方法来自Linux日常操作与基础知识|archlinux简明指南终端编辑器vim的使用我们需要掌握一个能在终端中进行文本编辑的软件,这里介绍vim。创建并编辑名为hello.txt​的文件:vimhello.txt此时可以看到进入了一个空的界面:​​此时处在vim的命......
  • API接口请求小结
    API接口请求小结一、python:API接口请求1.1multipart/form-data类型请求参数类型:数组1.2multipart/form-data类型请求参数类型:文件流1.3application/json类型请求参数类型:json请求方式:GET1.4application/json类型请求参数类型:json请求方式:POST二、apifo......
  • VIM与终端的灵活切换
    当处于VIM界面时,有时需要查看当前目录的其他文件,或者临时返回终端界面执行命令(编译、运行程序、或查看当前路径等),需要经过以下步骤:1.先输入":x"-->返回终端界面2.在终端界面执行命令3.然后再通过"vifilename"重新打开文件。这使得连续的工作流程被切分成了三个部分,增加......
  • nvim番外之将配置的插件管理器更新为lazy
    在很久以前我写过关于nvim配置的文章,里面推荐使用packer作为插件管理器。但是在一年多以前,packer的仓库中出现这么一段文字Thisrepositoryiscurrentlyunmaintained.Forthetimebeing(asofAugust,2023),itisrecommendedtouseoneofthefollowingpluginmanag......
  • 【Cadence or-CAD】tcl 脚本小结 A
    有一篇文章写的挺不错,就当是抛砖引玉吧,中间无脑粘贴发现有一点小问题。自动生成netalias;customizearraywiresplacingmethod#customizearraywiresplacingmethodprocca{netnamestart_numend_numargs}{setnetname[stringtoupper$netname]......
  • 半年小结 Vol3. 在大大的半导体行业挖呀挖
    “做硬件,核心不在硬件”,这半年历程得出了这么似乎有违常理的结论。做硬件是工程!工程!工程!做芯片是工程科学,而非纯理论科学。它有很多人为历史因素,并不是绝对客观的,整个系统更偏向有状态的动态系统,这与做纯理论科学研究是不同的。做工程很多时候,你做出来的东西并不是发现了某种普......
  • 【Linux系列】Vim 编辑器中的高效文本编辑技巧:删除操作
    ......
  • 【Vim Masterclass 笔记07】S05L19:Vim 剪切、复制、粘贴操作同步练习
    文章目录S05L19Vim剪切、复制、粘贴操作同步练习(Exercise05-Cut,CopyandPaste)1训练目标2操作指令2.1打开dyp.txt文件2.2交换文件的头两行2.3将文件首行put到文件其他为止2.4练习在光标位置的上方粘贴文本行2.5通过交换字符顺序更正存在的笔误2.6交换......
  • vscode+vim配置小记
    引入在windows系统下使用vscode+vim编写代码时会遇到一个令人略有不爽的小麻烦。在vim的normal模式下,首先需要进入insert模式才能正常编写。这里一般是在英文输入法键入相应字母才能进入,比如“i”和“o”我们进入insert模式之后,在敲代码的过程中难免会需要增加些中文注释,这个时......
  • Neovim(文本编辑器) v0.10.2 绿色版
    Vim是一款基于Vi编辑器的文本编辑器,Neovim是Vim的一个分支,旨在解决Vim的一些缺点并提供额外特性。Neovim具有更好的性能和稳定性,支持异步插件和脚本,改进了对现代用户界面和Unicode字符的支持。Neovim可在Windows、Linux、MacOS上安装,配置遵循XDG基本目录规范。软件特色简化维护......