Friday, August 26, 2011

Re: display faster output of external app

On 2011-08-26, niva wrote:
> Hi,
>
> I am calling an external app from vim like that :
>
> 1/ calling the application
> let g:output=system(s:cmd)
>
> 2/ deleting old returned value and updating with new one
> call s:OPC.AddValueAtEndOfFile(g:output)
>
> " Write value at end of line {{{1
> fun! s:OPC.AddValueAtEndOfFile(value)
> exe "norm ^f d$"
> exe "norm ^".s:maxlinelength."l"
> exe "norm a ".a:value
> endfunction
> ==============================================
>
> In fact this algo is called at each line to process in my entry file.
> I have done another method that do this task on several lines 10.
>
> Is there another way to make the call of external app or the update
> method faster ?

Maybe. You should first determine where the bottleneck is. It
makes no sense to spend a lot of time optimizing something that is
not the problem.

Try replacing "let g:output=system(s:cmd)" with "let g:output='hello'"
and see what effect that has on execution speed.

Then restore that line to its original form and try replacing your
function with one that does nothing, e.g.,

fun! s:OPC.AddValueAtEndOfFile(value)
endfunction

and see what effect that has on execution speed. Then you'll have a
better idea of what part of the code to work on.

Generally speaking, optimization of little parts of algorithms isn't
nearly as effective as choosing an optimum strategy for solving the
problem. For example, if you're really updating 10 or more lines,
your bottleneck may be executing s:cmd 10 times and a better
solution might be to execute s:cmd once with a parameter that tells
it to gather 10 results at once.

Regards,
Gary

--
You received this message from the "vim_use" 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

No comments: