diff options
Diffstat (limited to 'benchmark/crypto/cipher-stream.js')
-rw-r--r-- | benchmark/crypto/cipher-stream.js | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/benchmark/crypto/cipher-stream.js b/benchmark/crypto/cipher-stream.js index 9fd88f1d86..ca36bd736d 100644 --- a/benchmark/crypto/cipher-stream.js +++ b/benchmark/crypto/cipher-stream.js @@ -1,7 +1,7 @@ 'use strict'; -var common = require('../common.js'); +const common = require('../common.js'); -var bench = common.createBenchmark(main, { +const bench = common.createBenchmark(main, { writes: [500], cipher: [ 'AES192', 'AES256' ], type: ['asc', 'utf', 'buf'], @@ -17,24 +17,24 @@ function main(conf) { api = 'legacy'; } - var crypto = require('crypto'); - var assert = require('assert'); - var alice = crypto.getDiffieHellman('modp5'); - var bob = crypto.getDiffieHellman('modp5'); + const crypto = require('crypto'); + const assert = require('assert'); + const alice = crypto.getDiffieHellman('modp5'); + const bob = crypto.getDiffieHellman('modp5'); alice.generateKeys(); bob.generateKeys(); - var pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null; - var alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex'); - var bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex'); + const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null; + const alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex'); + const bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex'); // alice_secret and bob_secret should be the same assert(alice_secret === bob_secret); - var alice_cipher = crypto.createCipher(conf.cipher, alice_secret); - var bob_cipher = crypto.createDecipher(conf.cipher, bob_secret); + const alice_cipher = crypto.createCipher(conf.cipher, alice_secret); + const bob_cipher = crypto.createDecipher(conf.cipher, bob_secret); var message; var encoding; @@ -54,7 +54,7 @@ function main(conf) { throw new Error(`unknown message type: ${conf.type}`); } - var fn = api === 'stream' ? streamWrite : legacyWrite; + const fn = api === 'stream' ? streamWrite : legacyWrite; // write data as fast as possible to alice, and have bob decrypt. // use old API for comparison to v0.8 @@ -70,8 +70,8 @@ function streamWrite(alice, bob, message, encoding, writes) { bob.on('end', function() { // Gbits - var bits = written * 8; - var gbits = bits / (1024 * 1024 * 1024); + const bits = written * 8; + const gbits = bits / (1024 * 1024 * 1024); bench.end(gbits); }); @@ -96,6 +96,6 @@ function legacyWrite(alice, bob, message, encoding, writes) { written += dec.length; dec = bob.final(); written += dec.length; - var gbits = written / (1024 * 1024 * 1024); + const gbits = written / (1024 * 1024 * 1024); bench.end(gbits); } |