chore(benchmarks): lint happy

This commit is contained in:
Friedel Ziegelmayer 2016-11-07 11:37:32 +01:00
parent a7c2567ba2
commit 3cc26d167f
3 changed files with 30 additions and 28 deletions

View File

@ -33,5 +33,5 @@ suite
console.log(String(event.target)) console.log(String(event.target))
}) })
.run({ .run({
'async': true async: true
}) })

View File

@ -1,6 +1,8 @@
'use strict' 'use strict'
const Benchmark = require('benchmark') const Benchmark = require('benchmark')
const async = require('async')
const crypto = require('../src') const crypto = require('../src')
const suite = new Benchmark.Suite('key-stretcher') const suite = new Benchmark.Suite('key-stretcher')
@ -10,17 +12,28 @@ const keys = []
const ciphers = ['AES-128', 'AES-256', 'Blowfish'] const ciphers = ['AES-128', 'AES-256', 'Blowfish']
const hashes = ['SHA1', 'SHA256', 'SHA512'] const hashes = ['SHA1', 'SHA256', 'SHA512']
crypto.generateEphemeralKeyPair('P-256', (err, res) => { async.waterfall([
(cb) => crypto.generateEphemeralKeyPair('P-256', cb),
(res, cb) => res.genSharedKey(res.key, cb)
], (err, secret) => {
if (err) { if (err) {
throw err throw err
} }
res.genSharedKey(res.key, (err, secret) => { ciphers.forEach((cipher) => hashes.forEach((hash) => {
if (err) { setup(cipher, hash, secret)
throw err }))
}
ciphers.forEach((cipher) => { suite
hashes.forEach((hash) => { .on('cycle', (event) => {
console.log(String(event.target))
})
.run({
async: true
})
})
function setup (cipher, hash, secret) {
suite.add(`keyStretcher ${cipher} ${hash}`, (d) => { suite.add(`keyStretcher ${cipher} ${hash}`, (d) => {
crypto.keyStretcher(cipher, hash, secret, (err, k) => { crypto.keyStretcher(cipher, hash, secret, (err, k) => {
if (err) { if (err) {
@ -33,15 +46,4 @@ crypto.generateEphemeralKeyPair('P-256', (err, res) => {
}, { }, {
defer: true defer: true
}) })
}) }
})
})
})
suite
.on('cycle', (event) => {
console.log(String(event.target))
})
.run({
'async': true
})

View File

@ -48,5 +48,5 @@ suite
console.log(String(event.target)) console.log(String(event.target))
}) })
.run({ .run({
'async': true async: true
}) })