-
-
Save indutny/f37c466b4765e686b766b0b32557557c to your computer and use it in GitHub Desktop.
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 BN = require('./'); | |
function fill(num, storage) { | |
num.words = storage; | |
num.length = storage.length; | |
for (var i = 0; i < storage.length; i++) | |
num.words[i] = 0x3ffffff ^ i; | |
} | |
function bench(A, B, C) { | |
console.log(A.constructor.name); | |
const a = new BN(null); | |
const b = new BN(null); | |
const c = new BN(null); | |
fill(a, A); | |
fill(b, B); | |
fill(c, C); | |
const start = process.hrtime(); | |
for (var i = 0; i < 1e6; i++) | |
a.mulTo(b, c); | |
const delta = process.hrtime(start); | |
console.log(delta); | |
} | |
if (process.argv[2] === 'u') | |
bench(new Uint32Array(8), new Uint32Array(8), new Uint32Array(8)); | |
else | |
bench(new Array(8), new Array(8), new Array(8)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment