Tuesday, November 14, 2017

Re: Vim surprisingly slow?

On 2017-11-14 22:41, Christian Brabandt wrote:
> > > Also does it work better if you explicitly use e.g.
> > > writefile('', 'a')?
> >
> > Much faster!
> >
> > :g/.*name":"\([^"]*\)".*card":"\([^"]*\)".*/let
> > s=substitute(getline('.'),
> > '.*stamp":"\(\d\+\)-\(\d\+\)-\(\d\+\).*','\1\2\3','').'.txt'|s//\1,\2/|call
> > writefile([getline('.')], s, 'a')
> >
> >
> > runs in about the same time as the "echo" version or the "append
> > it to a list" version (i.e., one second or less).
>
> I am puzzled now. Is that buffer loaded? Perhaps Vim (re-)writes
> the undofile or needs to sync the swapfile?

I'm unsure about what is happening under the covers, but it's
consistent if all I do is

$ vim -u NONE data.json
:g/... " my initial lengthy :g command

with no syntax highlighting, no changes to the default environment.
It's about 5000 lines that get written, based on my rough wall-clock
timing, it's writing about 10 lines/second with the ".w!>>" version.
Meanwhile, the writefile() version is writing closer to 5000
lines/second.

-tim


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment