Tuesday, September 11, 2012

Re: Create a 1,000,000 byte file with VIM.

Dotan Cohen <dotancohen@gmail.com> wrote:

> I am trying to create a 1,000,000 byte file with VIM. The following
> has VIM using 100% of _both_ my CPUs (Intel DuoCore) for almost two
> hours before I killed it:
> ia<esc>1000000.
>
> /i assume that the holdup is not that 1000000 'a' characters are being
> written, but rather that insert mode is being inserted and left
> 1000000 times. Is there a better way, other than just doing the
> operation 1000 times, then copying that another 1000 times?
>
> Thanks.

That's interesting. Here are measurements
on my laptop:

$ time vim -u NONE \
-c 'call feedkeys("ia\<Esc>5000.:q!\<CR>", "n")'

Then replacing 5000 with 10000, 20000, 40000
I get those timings:

iterations time
--------- -------
5000 1.132s
10000 4.574s
20000 18.344s
40000 73.120s

Doubling the number of iterations makes
it 4 time slower (=> O(n^2)). I would not
expected that. Perhaps it can be improved.

Regards
-- Dominique

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