mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-05-31 23:31:02 +02:00
The find controller tests consistently show up in the list of slowest tests reported by Jasmine. Profiling shows that most of the time is spent waiting for the find results to arrive, even though the find command itself is quite fast. It turns out that the slowdown occurs between receiving the `find` event and actually triggering the search. The find controller has a hardcoded delay of 250 milliseconds built in, which was introduced for viewer performance many years ago because otherwise every keystroke would trigger a search even though the user's query was not complete yet. For the unit tests we don't need this delay because, contrary to the viewer use case, we don't have to account for user interaction and instead dispatch complete `find` events on the event bus ourselves. However, since the unit tests were introduced well over a year after the delay was introduced, due to an oversight it was never made configurable so we could skip it for the unit tests. This commit fixes the issue, which locally results in the runtime of `npx gulp unittest --noChrome` dropping from 39.991 seconds before this patch to 29.116 seconds afterwards, which is a 27% speedup.