Skip to content

Commit

Permalink
benchmark: replace seedable fixture generator
Browse files Browse the repository at this point in the history
Replace sha256-hash based generator to XorShift128+ from package xorshift.js
  • Loading branch information
fanatid authored and indutny committed Feb 16, 2016
1 parent fe6f651 commit 6582e29
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
14 changes: 7 additions & 7 deletions benchmarks/index.js
Expand Up @@ -2,19 +2,19 @@

var benchmark = require('benchmark');
var crypto = require('crypto');
var PRNG = require('./prng');
var bn = require('../');
var bignum = require('bignum');
var sjcl = require('eccjs').sjcl.bn;
var bigi = require('bigi');
var BigInteger = require('js-big-integer').BigInteger;
var SilentMattBigInteger = require('biginteger').BigInteger;
var XorShift128Plus = require('xorshift.js').XorShift128Plus;
var benchmarks = [];

var selfOnly = process.env.SELF_ONLY;
var seed = process.env.SEED || crypto.randomBytes(32).toString('hex');
var seed = process.env.SEED || crypto.randomBytes(16).toString('hex');
console.log('Seed: ' + seed);
var prng = new PRNG(seed);
var prng = new XorShift128Plus(seed);

var fixtures = [];
var findex = 0;
Expand Down Expand Up @@ -87,10 +87,10 @@ while (fixtures.length < 25) {
var fixture = {};
fixtures.push(fixture);

var a = prng.getHexString(64);
var b = prng.getHexString(64);
var aj = prng.getHexString(1536);
var bj = prng.getHexString(1536);
var a = prng.randomBytes(32).toString('hex');
var b = prng.randomBytes(32).toString('hex');
var aj = prng.randomBytes(768).toString('hex');
var bj = prng.randomBytes(768).toString('hex');

// BN
fixture.a1 = new bn(a, 16);
Expand Down
7 changes: 4 additions & 3 deletions benchmarks/package.json
Expand Up @@ -10,10 +10,11 @@
"license": "MIT",
"dependencies": {
"benchmark": "^1.0.0",
"bignum": "^0.11.0",
"eccjs": "^0.3.1",
"bigi": "*",
"biginteger": "*",
"js-big-integer": "*"
"bignum": "^0.11.0",
"eccjs": "^0.3.1",
"js-big-integer": "*",
"xorshift.js": "^1.0.0"
}
}
32 changes: 0 additions & 32 deletions benchmarks/prng.js

This file was deleted.

0 comments on commit 6582e29

Please sign in to comment.