[racket-dev] Potential search improvement

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Tue May 29 08:27:07 EDT 2012

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

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

> [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.
sam th
samth at ccs.neu.edu

Posted on the dev mailing list.