Created
March 9, 2021 13:25
-
-
Save monken/7ee463e6a1ed1582615ff1ada5e8628d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as crypto from 'crypto'; | |
const key = crypto.generateKeyPairSync('rsa', { | |
modulusLength: 2048, | |
}); | |
const input = crypto.randomBytes(128); | |
function run(iterations) { | |
for (let i = 0; i < iterations; i++) { | |
crypto.createSign('RSA-SHA256').update(input).sign(key.privateKey); | |
} | |
} | |
const start = process.hrtime.bigint(); | |
run(1000); | |
const end = process.hrtime.bigint(); | |
console.log(`took ${Number(end - start)/1000000} ms`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ami-0f10e11691c9ab660 (us-east-2) on a c6g.large | |
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash | |
source .nvm/nvm.sh | |
nvm install 15 | |
# compiling node 15 from source did not make a difference | |
# same results with NodeJS 14 | |
node benchmark.mjs | |
# output on a c6g.large | |
# took 3411.936128 ms | |
# output on a c5.large | |
# took 606.871429 ms | |
# output on a M1 Apple MacBook Pro | |
# took 577.953708 ms |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment