Originally posted on ivantanev.com
TL;DR
When you have Jest as your test runner, passing the --maxWorkers=50% option will make the te...
For further actions, you may consider blocking this person and/or reporting abuse
Thanks for sharing, I didn't expect such results! Didn't know about hyperfine either, that's an instant download for me
I tried running our CI tests with:
--maxWorkers=50%
: got worse from 13:30min to 15min--runInBand
: got worse from 13:30min to 22minMaybe I'm doing something wrong. Any insights?
I was looking at this for local development, and was surprised to see max-workers at 75% boosted a slow-running test from 30s to 10s. But then I put it back at 50% and it was still 10s, same without the option anyway. So that makes me wonder, why does jest speed up locally after a few runs? Even with no cache?
Because of local filesystem caches - instead of having to hit the hard drive, the OS will store file metadata (or sometimes whole files) in memory after they have been accessed.
To reliably measure performance, you must use something like hyperfine:
hyperfine 'npm test' -w 3 // Will first run 3 warmup runs to make sure caches are primed, and only then do timing runs.
What a great article.
Thank you for all the insights and demonstration of this
hyperfine
tool.Thanks for the article, how did you benchmark --watch?
You don't need to benchmark "--watch" as it's basically running your tests over and over again.
If you want to benchmark npm script, which uses watch, just pass
--watchAll=false
to disable watch for that scriptSure, I mean if that's adequate to measure runtime performance of watched tests I 'm fine.
This article is a godsend
This is really useful. My machine was extremely slow while running the jest tests, but now it's much better and my tests are also running faster.
neat, thanks for the benchmarking, definitely speeds up my tests locally
Super helpful article thank you.
Very useful, thank you! I liked the examples of configuration with CRA or with Jest alone. I saved ~20 seconds on a 65 seconds local test run, which is very appreciated. Will now test the CI version!
Hm, this didn't seem to work for me. I have a MBP with the M1 Max chip (10 cores) and after running hyperfine benchmark and the 10 workers was the fastest.
Great, thanks!!! This save my life.