Hi,

On Wed, Jun 10, 2020 at 8:22 AM Yegappan Lakshmanan <[email protected]>
wrote:

> Hi,
>
> On Sun, Jun 7, 2020 at 2:30 AM lacygoill <[email protected]>
> wrote:
>
>> @yegappan <https://github.com/yegappan> Thank you for working on this
>> feature.
>>
>> The more entries a quickfix list contains, the more costly the
>> 'quickfixtextfunc' seems to be.
>>
>> I tried to write what seems to be a simple function:
>>
>> fu QuickFixTextFunc(info) abort
>>
>>     if a:info.quickfix
>>
>>         let e = getqflist({'id': a:info.id, 'idx': a:info.idx, 'items': 
>> 1}).items[0]
>>
>>     else
>>
>>         let e = getloclist(0, {'id': a:info.id, 'idx': a:info.idx, 'items': 
>> 1}).items[0]
>>
>>     endif
>>
>>     let fname = fnamemodify(bufname(e.bufnr), ':t')
>>
>>     if strchars(fname, 1) <= 8
>>
>>         let fname = printf('%8s', fname)
>>
>>     else
>>
>>         let fname = printf('%.7s', fname)..'…'
>>
>>     endif
>>
>>     let lnum = printf('%5d', e.lnum)
>>
>>     let col = printf('%3d', e.col)
>>
>>     return fname..'|'..lnum..' col '..col..'| '..e.text
>>
>> endfu
>>
>>
>> And tested it with this command:
>>
>> $ vim -Nu NONE -S <(curl -Ls 
>> https://gist.githubusercontent.com/lacygoill/57d3cd8b5313159f42af43704ebfa7a8/raw/a255cbc37efe18319690943129d0abdf661c1434/profile_quickfixtextfunc.vim)
>>
>> :QfTf 8
>>
>>
>> On my machine, the test took about 2 minutes to complete. Here are the
>> results:
>>
>>    1000 entries:   0.001 seconds to run :copen
>>
>>                    0.039 seconds to run :copen with 'qftf'  39 times slower
>>
>>    2000 entries:   0.001 seconds to run :copen
>>
>>                    0.084 seconds to run :copen with 'qftf'  84 times slower
>>
>>    4000 entries:   0.003 seconds to run :copen
>>
>>                    0.190 seconds to run :copen with 'qftf'  63 times slower
>>
>>    8000 entries:   0.006 seconds to run :copen
>>
>>                    0.457 seconds to run :copen with 'qftf'  76 times slower
>>
>>   16000 entries:   0.012 seconds to run :copen
>>
>>                    1.260 seconds to run :copen with 'qftf'  105 times slower
>>
>>   32000 entries:   0.025 seconds to run :copen
>>
>>                    4.983 seconds to run :copen with 'qftf'  199 times slower
>>
>>   64000 entries:   0.054 seconds to run :copen
>>
>>                   23.322 seconds to run :copen with 'qftf'  431 times slower
>>
>>  128000 entries:   0.107 seconds to run :copen
>>
>>                   97.002 seconds to run :copen with 'qftf'  906 times slower
>>
>>
>> As you can see, for a quickfix list with more than a thousand entries,
>> 'quickfixtextfunc' makes :copen around a thousand times slower. And the
>> more entries, the slower the feature is.
>>
>> Do you think something could be done to prevent the function from being
>> called when the quickfix list contains too many entries? Maybe the option
>> could be set to a colon separated list of values: the name of the function
>> to format the entry in the quickfix window, and an optional number. When
>> the size of a quickfix list goes beyond that number, the function would not
>> be invoked to format the entry. It would be displayed as if the option was
>> not set.
>>
>>
>> I profiled the code with your test function. I see that the majority of
> the time is
> spent in the cleanup_function_call() function. This function is called
> after
> invoking a user defined function to cleanup the local hash table. I am not
> sure whether using a Vim9 type script will help here. I wlll also profile
> with
> a lambda function to see whether that will help.
>

Another alternative is to call the function for a range of lines in the
quickfix list
instead of for every line in the quickfix list. The function should return
a list
of strings (one per line).

- 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/CAAW7x7%3DfUC5oja3EY2fuMK_B8Y3CfcwkWwasDrT%3D4r%3DfYgDVQQ%40mail.gmail.com.

Raspunde prin e-mail lui