Files
rust/library/test/src
Rain bbb9e3bb4a libtest: use binary search for --exact test filtering
The test array is sorted by name at compile time. When `--exact` is
passed in, use binary search for O(f log n) lookups instead of an O(n)
linear scan, under the assumption that f << n (which is true for the
most relevant cases).

This is important for Miri, where the interpreted execution makes the
linear scan very expensive.

I measured this against a repo with 1000 empty tests, running
`cargo +stage1 miri nextest run test_00` (100 tests) under hyperfine:

* Before (linear scan): 49.7s ± 0.6s
* After (binary search): 41.9s ± 0.2s  (-15.7%)

I also tried a few other variations (particularly swapping matching tests to the front of the list + truncating the list), but the index + swap_remove approach proved to be the fastest.

Questions:

- [ ] To be conservative, I've assumed that test_main can potentially receive an unsorted list of tests. Is this assumption correct?
2026-04-05 21:11:49 -07:00
..
2026-02-25 22:51:53 +08:00
2025-01-20 18:46:29 +01:00
2025-01-20 18:46:29 +01:00
2024-07-26 13:26:33 +01:00
2026-02-25 22:51:53 +08:00
2025-01-20 18:46:29 +01:00