-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cryptographic operations are 150 times slower in Jest compared to node #9006
Comments
This is a duplicate of #5163. Adding {
"jest": {
"extraGlobals": ["Math"]
}
} |
Wow, that simple config change has the test running in 600 ms now on my laptop. That's a 100x improvement! Thanks @SimenB |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🐛 Bug Report
When I run a JS function that does cryptographic operations on node.js is takes around 400 milliseconds. When I run the exact same JS code in a Jest test, it takes a minute.
To Reproduce
Then create a js file with the following code. eg
commitPerfTest.js
Run the code. On my MacBook Pro this takes around 400ms
Now run the above code in a Jest test. eg
commitPerf.test.js
Now run the Jest test assuming you have Jest installed globally
On my laptop, the last
params.commit(gExp, hExp, bn128.randomScalar());
line takes around 60000 milliseconds. I've also tested with Jest 23 and 22 and they also take around one minute.Expected behavior
I'd expect Jest to add some overhead and could live with it being 2, even up to 10 times, slower than node. But 150 times slower is unworkable.
Link to repl or repo (highly encouraged)
https://github.com/jpmorganchase/anonymous-zether
Consensys/anonymous-zether#12 (comment)
envinfo
I was testing using Jest 24.9.0
System:
OS: macOS Mojave 10.14.6
CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Binaries:
Node: 12.11.1 - ~/.nvm/versions/node/v12.11.1/bin/node
Yarn: 1.19.0 - /usr/local/bin/yarn
npm: 6.11.3 - ~/.nvm/versions/node/v12.11.1/bin/npm
The text was updated successfully, but these errors were encountered: