[racket-dev] Potential search improvement

From: Eli Barzilay (eli at barzilay.org)
Date: Tue May 29 10:00:24 EDT 2012

An hour and a half ago, Sam Tobin-Hochstadt wrote:
> On Tue, May 29, 2012 at 8:16 AM, Eli Barzilay <eli at barzilay.org> wrote:
> > 20 minutes ago, Sam Tobin-Hochstadt wrote:
> >> On Tue, May 29, 2012 at 7:33 AM, Eli Barzilay <eli at barzilay.org> wrote:
> >> > That can currently get to ~20k things to sort and adjust for
> >> > additional entries that get added on each release, planet
> >> > packages, etc.
> >>
> >> Have you measured how long this takes? On my machine, the
> >> `sort()` method on an array of 25000 strings takes 11ms in
> >> Firefox.
> >
> > I didn't, but my worry is about older machines (and things like
> > IE).
> I think that (a) this isn't going to be a big deal for any systems,
> especially if you filter out the 0 scores first, and (b) that we
> should be optimizing for people who are or might become Racket
> developers, who will overwhelmingly have modern systems and browsers
> (including IE 9, which I bet is very fast on this).

The sorting happens on each and every update, which can happen after
every key -- and there are still schools that have old browsers with
slow machines.  (We've been through this discussion before, BTW.)

> > This wouldn't be an issue if I could abort the sort when there's new
> > user input -- but JS being what it is, once it starts sorting I can't
> > stop it until it's done, which means that new input characters need to
> > wait for the sort.
> To stop the sort in the middle, use a custom comparison function, a
> bit of state, and an exception.

This might work.

> > [Another option that would help is if there's a reliable (and
> > user-invisible) way to find out how fast things run and adjust the
> > delay before firing a new sort on slower machines.]
> There are a couple options here -- check for particular browsers
> (using `navigator.userAgent`), or run some test like sorting a bunch
> of numbers.

(The user agent is useless; a test requires running for some
measurable time which might interfere with typing and there's also the
non-trivial job of finding some good way to infer a good delay for the
resulting timer.)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

Posted on the dev mailing list.