Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork6.5k
Long term benchmark ofvim.loader#36905
lewis6991 started this conversation inShow and tell
-
I was interested to see what the long term benefits of using I added the following code at the start of my
Click to expandlocalstart=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,}) ResultsMacbook Pro with M4 ProTime 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 HPCTime 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), Please share if anyone has any different findings. |
BetaWas this translation helpful?Give feedback.
All reactions
👍 2
Replies: 0 comments
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment