Skip to content

Commit

Permalink
benchmark: add crypto.randomBytes()
Browse files Browse the repository at this point in the history
As per request
[here](nodejs#632 (comment)).
  • Loading branch information
brendanashworth committed Apr 24, 2015
1 parent 3d3083b commit e71875b
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions benchmark/crypto/random-bytes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var common = require('../common');
var randomBytes = require('crypto').randomBytes;
var bench = common.createBenchmark(main, {
n: [1e5],
len: [32, 64, 128, 256, 1024]
});

function main(conf) {
var len = conf.len | 0;
var n = conf.n | 0;

bench.start();

for (var i = 0; i < n; i++) {
randomBytes(len);
}

bench.end(n);
}

0 comments on commit e71875b

Please sign in to comment.