Hi,
On Fri, Nov 19, 2021 at 5:27 AM lacygoill <[email protected]> wrote:
> Interestingly enough, :highlight is faster than hlset():
>
> vim9scriptvar time = reltime()def Func()
> for i: number in range(100'000)
> highlight ErrorMsg term=standout ctermfg=253 ctermbg=168
> guifg=#dadada guibg=#d75f87
> endforenddefFunc()
> (reltime(time)->reltimestr()->matchstr('.*\..\{,3}') .. ' seconds to run
> Func()')->setline(1)
>
> 0.343 seconds to run Func()
>
> vim9scriptvar time = reltime()def Func()
> for i: number in range(100'000)
> [{
> name: 'ErrorMsg',
> ctermfg: '253',
> ctermbg: '168',
> guibg: '#d75f87',
> guifg: '#dadada',
> term: {standout: true},
> }]->hlset()
> endforenddefFunc()
> (reltime(time)->reltimestr()->matchstr('.*\..\{,3}') .. ' seconds to run
> Func()')->setline(1)
>
> 0.511 seconds to run Func()
>
> The discrepancy is more pronounced at the script level:
>
> vim9scriptvar time = reltime()for i in range(100'000)
> highlight ErrorMsg term=standout ctermfg=253 ctermbg=168 guifg=#dadada
> guibg=#d75f87endfor
> (reltime(time)->reltimestr()->matchstr('.*\..\{,3}') .. ' seconds to run the
> script')->setline(1)
>
> 0.523 seconds to run the script
>
> vim9scriptvar time = reltime()for i: number in range(100'000)
> [{
> name: 'ErrorMsg',
> ctermfg: '253',
> ctermbg: '168',
> guibg: '#d75f87',
> guifg: '#dadada',
> term: {standout: true},
> }]->hlset()endfor
> (reltime(time)->reltimestr()->matchstr('.*\..\{,3}') .. ' seconds to run the
> script')->setline(1)
>
> 1.268 seconds to run the script
>
>
>
I took a look at this issue. It looks like just populating the attributes
itself takes time. For example,
if you source the following script:
vim9script
var time = reltime()
var attr: list<dict<any>>
for i: number in range(100'000)
attr = [{
name: 'ErrorMsg',
ctermfg: '253',
ctermbg: '168',
guibg: '#d75f87',
guifg: '#dadada',
term: {standout: true},
}]
endfor
(reltime(time)->reltimestr()->matchstr('.*\..\{,3}') .. ' seconds to run
the script')->setline(1)
The above script takes around 0.630 seconds in my setup (without any calls
to hlset()).
So it looks like most of the time is spent outside of the hlset() function.
Regards,
Yegappan
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kjzJ-CS_3%3DhD3OiZ4MRpgrDCgW8jrrbmjUH352yYSSvg%40mail.gmail.com.