Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Long term benchmark ofvim.loader#36905

lewis6991 started this conversation inShow and tell
Discussion options

I was interested to see what the long term benefits of usingvim.loader were as comparing individual runs isn't representative of real world usage.

I added the following code at the start of myinit.lua which does the follow:

  1. Generate a random boolean
  2. Use boolean to decide whether to runvim.loader.enable()
  3. Creates aVimEnter autocmd which measures the startup time of that session
  4. Appends this information to a log file.
Click to expand
localstart=vim.uv.hrtime()-- Random booleanlocalenable_loader=vim.uv.random(1):byte(1)%2==1ifenable_loaderthenvim.loader.enable()end--- @paramtnumber[]--- @returnnumber?localfunctionmedian(t)table.sort(t)localn=#tifn==0thenreturnendifn%2==1thenreturnt[math.ceil(n/2)]elsereturn (t[n/2]+t[n/2+1])/2endendvim.api.nvim_create_autocmd('VimEnter', {callback=function()localstartuptime= (vim.uv.hrtime()-start)/1e6locallogpath=vim.fs.joinpath(vim.env.HOME,'.nvim_startuptime.log')localstats= {enabled= {avg=0,high=0,low=math.huge,cnt=0,      },disabled= {avg=0,high=0,low=math.huge,cnt=0,      },    }localenabled_time=0localdisabled_time=0ifenable_loaderthenenabled_time=enabled_time+startuptimeelsedisabled_time=disabled_time+startuptimeend-- Read logifvim.uv.fs_stat(logpath)thenlocalenabled_times= {}--- @typeinteger[]localdisabled_times= {}--- @typeinteger[]forlineinio.lines(logpath)do--- @typestring,stringlocalstate,time_str=line:match('%w+: Loader (.+), ([^ ]+)ms')localtime=tonumber(time_str)--[[@as number]]ifstate=='enabled'thenstats.enabled.cnt=stats.enabled.cnt+1stats.enabled.high=math.max(stats.enabled.high,time)stats.enabled.low=math.min(stats.enabled.low,time)enabled_time=enabled_time+timeenabled_times[#enabled_times+1]=timeelseifstate=='disabled'thenstats.disabled.cnt=stats.disabled.cnt+1stats.disabled.high=math.max(stats.disabled.high,time)stats.disabled.low=math.min(stats.disabled.low,time)disabled_time=disabled_time+timedisabled_times[#disabled_times+1]=timeelseerror('invalid:'..line)endendstats.enabled.avg=enabled_time/stats.enabled.cntstats.disabled.avg=disabled_time/stats.disabled.cntstats.enabled.median=median(enabled_times)stats.disabled.median=median(disabled_times)end-- update logassert(io.open(logpath,'a+')):write(      ('%s: %s, %sms, avg: %sms\n'):format(os.date(),enable_loaderand'Loader enabled'or'Loader disabled',startuptime,enable_loaderandstats.enabled.avgorstats.disabled.avg      )    )vim.g.loader_stats=statsend,})

Results

Macbook Pro with M4 Pro

Time span: 2025-04-01 to 2025-12-10

{disabled= {avg=400.12021034455,cnt=2734,high=8568.989292,low=26.772709,median=165.358146  },enabled= {avg=381.35570085946,cnt=2718,high=9242.460083,low=24.287917,median=163.835604  }}

Linux VM running RHE8 on HPC

Time span: 2025-08-26 to 2025-12-10

{disabled= {avg=503.35068218437,cnt=678,high=6218.220384,low=65.781768,median=427.41898  },enabled= {avg=579.21986082869,cnt=718,high=18031.75088,low=143.11936,median=420.963864  }}

So it seems from my test that (for the platforms I run),vim.loader.enable() provides negligle performance benefits.

Please share if anyone has any different findings.

You must be logged in to vote

Replies: 0 comments

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
performanceperformance, latency, cpu/memory usage
1 participant
@lewis6991

[8]ページ先頭

©2009-2025 Movatter.jp