Skip to content

Commit

Permalink
benchmarks: reduce number of libraries
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Oct 17, 2014
1 parent db77689 commit 0bf5d7d
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 72 deletions.
70 changes: 0 additions & 70 deletions benchmarks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ var assert = require('assert');
var benchmark = require('benchmark');
var bn = require('../');
var bignum = require('bignum');
var bbignum = require('browserify-bignum');
var sjcl = require('eccjs').sjcl.bn;
var bigi = require('bigi');
var BigInteger = require('js-big-integer').BigInteger;
var NodeBigInteger = require('node-biginteger');
var SilentMattBigInteger = require('biginteger').BigInteger;
var benchmarks = [];

bbignum.config({
DECIMAL_PLACES: 0,
ROUNDING_MODE: 1,
EXPONENTIAL_AT: 1048576
});

function add(op, obj) {
benchmarks.push({
name: op,
Expand Down Expand Up @@ -67,9 +59,6 @@ var b1 = new bn('213509123601923760129376102397651203958123402314875', 10);
var a2 = new bignum('012345678901234567890123456789012345678901234567890', 10);
var b2 = new bignum('213509123601923760129376102397651203958123402314875', 10);

var a3 = new bbignum('012345678901234567890123456789012345678901234567890', 10);
var b3 = new bbignum('213509123601923760129376102397651203958123402314875', 10);

var a4 = new bigi('012345678901234567890123456789012345678901234567890', 10);
var b4 = new bigi('213509123601923760129376102397651203958123402314875', 10);

Expand All @@ -79,19 +68,14 @@ var b5 = new sjcl(b1.toString(16));
var a6 = new BigInteger('012345678901234567890123456789012345678901234567890', 10);
var b6 = new BigInteger('213509123601923760129376102397651203958123402314875', 10);

var a7 = NodeBigInteger.fromString('012345678901234567890123456789012345678901234567890', 10);
var b7 = NodeBigInteger.fromString('213509123601923760129376102397651203958123402314875', 10);

var a8 = SilentMattBigInteger.parse('012345678901234567890123456789012345678901234567890', 10);
var b8 = SilentMattBigInteger.parse('213509123601923760129376102397651203958123402314875', 10);

var as1 = a1.mul(a1).iaddn(0xdeadbeef);
var as2 = a2.mul(a2).add(0xdeadbeef);
var as3 = a3.mul(a3).add(0xdeadbeef);
var as4 = a4.multiply(a4).add(bigi.valueOf(0xdeadbeef));
var as5 = a5.mul(a5).add(0xdeadbeef);
var as6 = a6.multiply(a6).add(new BigInteger('deadbeef', 16));
var as7 = a7.multiply(a7).add(NodeBigInteger.fromString('deadbeef', 16));
var as8 = a8.multiply(a8).add(SilentMattBigInteger.parse('deadbeef', 16));

add('create-10', {
Expand All @@ -101,18 +85,12 @@ add('create-10', {
'bignum': function() {
new bignum('012345678901234567890123456789012345678901234567890', 10);
},
'browserify-bignum': function() {
new bbignum('012345678901234567890123456789012345678901234567890', 10);
},
'bigi': function() {
new bigi('012345678901234567890123456789012345678901234567890', 10);
},
'yaffle': function() {
new BigInteger('012345678901234567890123456789012345678901234567890', 10);
},
'node-biginteger': function() {
NodeBigInteger.fromString('012345678901234567890123456789012345678901234567890', 10);
},
'silentmatt-biginteger': function() {
SilentMattBigInteger.parse('012345678901234567890123456789012345678901234567890', 10);
}
Expand All @@ -125,9 +103,6 @@ add('create-hex', {
'bignum': function() {
new bignum('01234567890abcdef01234567890abcdef01234567890abcdef', 16);
},
'browserify-bignum': function() {
new bbignum('01234567890abcdef01234567890abcdef01234567890abcdef', 16);
},
'bigi': function() {
new bigi('01234567890abcdef01234567890abcdef01234567890abcdef', 16);
},
Expand All @@ -137,9 +112,6 @@ add('create-hex', {
'yaffle': function() {
new BigInteger('01234567890abcdef01234567890abcdef01234567890abcdef', 16);
},
'node-biginteger': function() {
NodeBigInteger.fromString('01234567890abcdef01234567890abcdef01234567890abcdef', 16);
},
'silentmatt-biginteger': function() {
SilentMattBigInteger.parse('012345678901234567890123456789012345678901234567890', 16);
}
Expand All @@ -152,18 +124,12 @@ add('toString-10', {
'bignum': function() {
a2.toString(10);
},
'browserify-bignum': function() {
a3.toString(10);
},
'bigi': function() {
a4.toString(10);
},
'yaffle': function() {
a6.toString(10);
},
'node-biginteger': function() {
a7.toString(10);
},
'silentmatt-biginteger': function() {
a8.toString(10);
}
Expand All @@ -176,9 +142,6 @@ add('toString-hex', {
'bignum': function() {
a2.toString(16);
},
'browserify-bignum': function() {
a3.toString(16);
},
'bigi': function() {
a4.toString(16);
},
Expand All @@ -188,9 +151,6 @@ add('toString-hex', {
'yaffle': function() {
a6.toString(16)
},
'node-biginteger': function() {
a7.toString(16);
},
'silentmatt-biginteger': function() {
a8.toString(16);
}
Expand All @@ -203,9 +163,6 @@ add('add', {
'bignum': function() {
a2.add(b2);
},
'browserify-bignum': function() {
a3.add(b3);
},
'bigi': function() {
a4.add(b4);
},
Expand All @@ -215,9 +172,6 @@ add('add', {
'yaffle': function() {
a6.add(b6);
},
'node-biginteger': function() {
a7.add(b7);
},
'silentmatt-biginteger': function() {
a8.add(a8);
}
Expand All @@ -230,9 +184,6 @@ add('mul', {
'bignum': function() {
a2.mul(b2);
},
'browserify-bignum': function() {
a3.mul(b3);
},
'bigi': function() {
a4.multiply(b4);
},
Expand All @@ -242,9 +193,6 @@ add('mul', {
'yaffle': function() {
a6.multiply(b6);
},
'node-biginteger': function() {
a7.multiply(b7);
},
'silentmatt-biginteger': function() {
a8.multiply(b8);
}
Expand All @@ -257,9 +205,6 @@ add('sqr', {
'bignum': function() {
a2.mul(a2);
},
'browserify-bignum': function() {
a3.mul(a3);
},
'bigi': function() {
a4.square();
},
Expand All @@ -269,9 +214,6 @@ add('sqr', {
'yaffle': function() {
a6.multiply(a6);
},
'node-biginteger': function() {
a7.square();
},
'silentmatt-biginteger': function() {
a8.multiply(a8);
}
Expand All @@ -284,18 +226,12 @@ add('div', {
'bignum': function() {
as2.div(a2);
},
'browserify-bignum': function() {
as3.div(a3);
},
'bigi': function() {
as4.divide(a4);
},
'yaffle': function() {
as6.divide(a6);
},
'node-biginteger': function() {
a7.divide(b7);
},
'silentmatt-biginteger': function() {
a8.divide(a8);
}
Expand All @@ -308,9 +244,6 @@ add('mod', {
'bignum': function() {
as2.mod(a2);
},
'browserify-bignum': function() {
as3.mod(a3);
},
'bigi': function() {
as4.mod(a4);
},
Expand All @@ -320,9 +253,6 @@ add('mod', {
remainder.add(a6) :
remainder;
},
'node-biginteger': function() {
return as7.mod(a7);
},
'silentmatt-biginteger': function() {
var remainder = as8.remainder(a8);
return remainder.compare(BigInteger.ZERO) < 0 ?
Expand Down
2 changes: 0 additions & 2 deletions benchmarks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
"dependencies": {
"benchmark": "^1.0.0",
"bignum": "^0.6.2",
"browserify-bignum": "^1.3.0-2",
"eccjs": "^0.3.1",
"bigi": "*",
"node-biginteger": "*",
"biginteger": "*",
"js-big-integer": "*"
}
Expand Down

0 comments on commit 0bf5d7d

Please sign in to comment.