Re: wish: show search progress on slow searches

2007-04-30 Thread Yakov Lerner

On 4/29/07, Yakov Lerner <[EMAIL PROTECTED]> wrote:

On 4/29/07, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
>
> Yakov Lerner wrote:
>
> > Wish: when search is slow, show the progress line number
> > every second on the bottom line (like, 12345 of 9).
>
> What is slow?
To my taste, when something takes longer than 1-2 sec,
I'd prefer some visual feedback on the progress.

> Checking if the second passed will make the search even slower.
> Checking time is quite slow on some systems (the check for CTRL-C
> suffers from this).

Checking for time every several hundred (N) lines will probably not slow
the search perceptibly. N can be configurable, a parameter.
Some value between 10 and 1000 will probaby be reasonable.

Yakov



I think it's possibe to check for time, which searching, not too
often and not too seldom, even without user-defined parameter.
Adaptive algorithm with two counters will find the right rate or
time-checking:

- as we start search, we check time every 50 lines
(N=50 is initial value of N). We maintain counter M. M is how
many times we called time() between the seconds changed.
M is checked and reset every second. M is checked as folllows:

- If M is too high (M>10), then we adjust N by increasing it.
If M is too low(M<10), then we adjust N by decreasing it. Ideally,
we want to check time() ~10 times per second. (overhead of 10
calls to time() per second cannot he high, right ?)

- if search progresses for several seconds, then N quickly converges
to the "ideal" value (~10 checks/sec).

- we start every search with same value of N (say, 50). If search
is slow, then N will quickly converge to the "ideal" value for this regex,
the value in which where time() is checked ~10 times per second.

Yakov


Re: wish: show search progress on slow searches

2007-04-29 Thread Yakov Lerner

On 4/29/07, Bram Moolenaar <[EMAIL PROTECTED]> wrote:


Yakov Lerner wrote:

> Wish: when search is slow, show the progress line number
> every second on the bottom line (like, 12345 of 9).

What is slow?

To my taste, when something takes longer than 1-2 sec,
I'd prefer some visual feedback on the progress.


Checking if the second passed will make the search even slower.
Checking time is quite slow on some systems (the check for CTRL-C
suffers from this).


Checking for time every several hundred (N) lines will probably not slow
the search perceptibly. N can be configurable, a parameter.
Some value between 10 and 1000 will probaby be reasonable.

Yakov


Re: wish: show search progress on slow searches

2007-04-29 Thread Bram Moolenaar

Yakov Lerner wrote:

> Wish: when search is slow, show the progress line number
> every second on the bottom line (like, 12345 of 9).

What is slow?

Checking if the second passed will make the search even slower.
Checking time is quite slow on some systems (the check for CTRL-C
suffers from this).

> Maybe this can be done with plugin, I'm not sure.

Probably not without a big performance hit.

> Maybe simply status line can be refreshed once in a second,
> temporarily setting line number to the current search position.

That would be confusing.  Need to show it somewhere else (but where?).

> Some regexes take half minute to several minutes time on multimegabyte
> file. It would be nice to see the progress numbers onscreen.

True.  Some of my functions also echo the current line number now and
then.

-- 
"You know, it's at times like this when I'm trapped in a Vogon airlock with
a man from Betelgeuse and about to die of asphyxiation in deep space that I
really wish I'd listened to what my mother told me when I was young!"
"Why, what did she tell you?"
"I don't know, I didn't listen!"
-- Arthur Dent and Ford Prefect in Douglas Adams'
   "The Hitchhiker's Guide to the Galaxy"

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///