-
-
Save mattpodwysocki/dce70b79c263b70875c1 to your computer and use it in GitHub Desktop.
Benchmarks for HKDF
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
$ node -v | |
v5.5.0 | |
$ node benchmark.js | |
HKDF test x 488 ops/sec ±0.81% (82 runs sampled) | |
Fastest is HKDF test | |
$ jx -jxv | |
v0.3.1.1 | |
$ jx benchmark.js | |
HKDF test x 823 ops/sec ±0.40% (87 runs sampled) | |
Fastest is HKDF test |
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
'use strict'; | |
var Benchmark = require('benchmark'); | |
var crypto = require('crypto'); | |
var HKDF = require('./NextGeneration/hkdf'); | |
var suite = new Benchmark.Suite(); | |
// add tests | |
suite.add('HKDF test', function() { | |
var pubKey = crypto.createECDH('secp256k1').generateKeys(); | |
var expirationBuffer = crypto.randomBytes(8); | |
var sxy = crypto.createECDH('secp256k1'); | |
sxy.generateKeys(); | |
sxy = sxy.computeSecret(pubKey); | |
HKDF('sha256', sxy, expirationBuffer).derive('', 32); | |
}) | |
// add listeners | |
.on('cycle', function(event) { | |
console.log(String(event.target)); | |
}) | |
.on('complete', function() { | |
console.log('Fastest is ' + this.filter('fastest').map('name')); | |
}) | |
// run async | |
.run({ 'async': true }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment