mirror of
https://github.com/fluencelabs/js-libp2p-crypto
synced 2025-03-15 19:50:58 +00:00
chore(benchmarks): lint happy
This commit is contained in:
parent
a7c2567ba2
commit
3cc26d167f
@ -33,5 +33,5 @@ suite
|
|||||||
console.log(String(event.target))
|
console.log(String(event.target))
|
||||||
})
|
})
|
||||||
.run({
|
.run({
|
||||||
'async': true
|
async: true
|
||||||
})
|
})
|
||||||
|
@ -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,38 +12,38 @@ 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) => {
|
|
||||||
hashes.forEach((hash) => {
|
|
||||||
suite.add(`keyStretcher ${cipher} ${hash}`, (d) => {
|
|
||||||
crypto.keyStretcher(cipher, hash, secret, (err, k) => {
|
|
||||||
if (err) {
|
|
||||||
throw err
|
|
||||||
}
|
|
||||||
|
|
||||||
keys.push(k)
|
suite
|
||||||
d.resolve()
|
.on('cycle', (event) => {
|
||||||
})
|
console.log(String(event.target))
|
||||||
}, {
|
})
|
||||||
defer: true
|
.run({
|
||||||
})
|
async: true
|
||||||
})
|
|
||||||
})
|
})
|
||||||
})
|
|
||||||
})
|
})
|
||||||
|
|
||||||
suite
|
function setup (cipher, hash, secret) {
|
||||||
.on('cycle', (event) => {
|
suite.add(`keyStretcher ${cipher} ${hash}`, (d) => {
|
||||||
console.log(String(event.target))
|
crypto.keyStretcher(cipher, hash, secret, (err, k) => {
|
||||||
})
|
if (err) {
|
||||||
.run({
|
throw err
|
||||||
'async': true
|
}
|
||||||
|
|
||||||
|
keys.push(k)
|
||||||
|
d.resolve()
|
||||||
|
})
|
||||||
|
}, {
|
||||||
|
defer: true
|
||||||
})
|
})
|
||||||
|
}
|
||||||
|
@ -48,5 +48,5 @@ suite
|
|||||||
console.log(String(event.target))
|
console.log(String(event.target))
|
||||||
})
|
})
|
||||||
.run({
|
.run({
|
||||||
'async': true
|
async: true
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user