bignum to buffer: 33910 operations/second.
bn to array: 40950 operations/second.
bignum from buffer: 128041 operations/second.
bn from buffer: 1000000 operations/second.
bignum from buffer toString: 90334 operations/second.
bn from buffer toString: 12151 operations/second.
Last active
August 29, 2015 14:00
-
-
Save tlivings/11327317 to your computer and use it in GitHub Desktop.
bignum vs bn.js
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
var anvil = require('anvil'), | |
bignum = require('bignum'), | |
bn = require('bn.js'); | |
anvil('Bignum functions', function (forge, hammer) { | |
var bigBuffer, bigString; | |
bigBuffer = new Buffer([ 24, 7, 144, 87, 61, 194, 2, 7 ]); | |
bigString = '1731511286119924231'; | |
forge.after(function (error, results) { | |
results.forEach(function (report) { | |
console.log('%s: %d operations/second.', report.name, report.ops); | |
}); | |
}); | |
forge.add('bignum to buffer', function () { | |
bignum(bigString).toBuffer(); | |
}); | |
forge.add('bn to array', function () { | |
new bn(bigString).toArray(); | |
}); | |
forge.add('bignum from buffer', function () { | |
bignum.fromBuffer(bigBuffer); | |
}); | |
forge.add('bn from buffer', function () { | |
new bn(bigBuffer); | |
}); | |
forge.add('bignum from buffer toString', function () { | |
bignum.fromBuffer(bigBuffer).toString(); | |
}); | |
forge.add('bn from buffer toString', function () { | |
new bn(bigBuffer).toString(); | |
}); | |
hammer(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment