Skip to content

Instantly share code, notes, and snippets.

@mattpodwysocki
Last active February 10, 2016 22:13
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mattpodwysocki/dce70b79c263b70875c1 to your computer and use it in GitHub Desktop.
Save mattpodwysocki/dce70b79c263b70875c1 to your computer and use it in GitHub Desktop.
Benchmarks for HKDF
$ 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
'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