You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
git clone https://github.com/jpmorganchase/anonymous-zether
cd anonymous-zether/packages/anonymous.js/
npm i
cd src
Then create a js file with the following code. eg commitPerfTest.js
const{ GeneratorParams, FieldVector }=require("./prover/algebra.js");constbn128=require("./utils/bn128.js");constparams=newGeneratorParams();params.extend(64);constgExp=newFieldVector(Array.from({length: 64}).map(bn128.randomScalar));consthExp=newFieldVector(Array.from({length: 64}).map(bn128.randomScalar));conststartTime=newDate();params.commit(gExp,hExp,bn128.randomScalar());constendTime=newDate();console.log(`Commit took ${endTime-startTime} milliseconds`);
Run the code. On my MacBook Pro this takes around 400ms
node commitPerfTest.js
Now run the above code in a Jest test. eg commitPerf.test.js
Now run the Jest test assuming you have Jest installed globally
jest commitPerf.test.js
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.
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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
🐛 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: