-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Description
Prerequisites
- Checked that your issue hasn't already been filed by cross-referencing issues with the
faqlabel - Checked next-gen ES issues and syntax problems by using the same environment and/or transpiler configuration without Mocha to ensure it isn't just a feature that actually isn't supported in the environment in question or a bug in your code.
- 'Smoke tested' the code to be tested by running it outside the real test suite to get a better sense of whether the problem is in the code under test, your usage of Mocha, or Mocha itself
- Ensured that there is no discrepancy between the locally and globally installed versions of Mocha. You can find them with:
node node_modules/.bin/mocha --version(Local) andmocha --version(Global). We recommend avoiding the use of globally installed Mocha.
Description
mocha's CLI startup time is very slow. findup-sync appears to be a culprit, coupled with the fact that mocha loads findup-sync twice since it spawns a child-process.
node -e "require('findup-sync')" is taking at least half a second on my Windows box. Windows suffers from higher per-file FS overhead, but I think this is still way too slow, considering that findup is barely doing anything.
findup-sync indirectly loads fast-glob, micromatch, and nanomatch, which internally do some sort of initialization of compilers and parsers for their glob pattern handling. I think these compilers are meant to be super-fast, but ironically all the extra complexity means they initialize pretty slowly. mrmlnc/fast-glob#92
Would you accept a PR that replaces mocha's usage of findup with a faster while() loop?
Are there specific globbing behaviors you want to preserve? I see that findup-sync is used for .mochrc discovery and package-file discovery. The former definitely doesn't need glob support; I'm unsure about the latter.
Steps to Reproduce
I've been adding console.time() and console.timeEnd() statements to mocha's code to track down which require() calls are the slowest.
Versions
mocha v6.0.0-1
node v11.3.0