|
|
@ -14,6 +14,45 @@ console.log('Benchmarking Block/Transaction Serialization'); |
|
|
|
console.log('---------------------------------------'); |
|
|
|
|
|
|
|
async.series([ |
|
|
|
function(next) { |
|
|
|
|
|
|
|
var buffers = []; |
|
|
|
console.log('Generating Random Test Data...'); |
|
|
|
for (var i = 0; i < 100; i++) { |
|
|
|
var br = new bitcore.encoding.BufferWriter(); |
|
|
|
var num = Math.round(Math.random() * 10000000000000); |
|
|
|
br.writeUInt64LEBN(new bitcore.crypto.BN(num)); |
|
|
|
buffers.push(br.toBuffer()); |
|
|
|
} |
|
|
|
|
|
|
|
var c = 0; |
|
|
|
var bn; |
|
|
|
|
|
|
|
function readUInt64LEBN() { |
|
|
|
if (c >= buffers.length) { |
|
|
|
c = 0; |
|
|
|
} |
|
|
|
var buf = buffers[c]; |
|
|
|
var br = new bitcore.encoding.BufferReader(buf); |
|
|
|
bn = br.readUInt64LEBN(); |
|
|
|
c++; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('Starting benchmark...'); |
|
|
|
|
|
|
|
var suite = new benchmark.Suite(); |
|
|
|
suite.add('bufferReader.readUInt64LEBN()', readUInt64LEBN, {maxTime: maxTime}); |
|
|
|
suite |
|
|
|
.on('cycle', function(event) { |
|
|
|
console.log(String(event.target)); |
|
|
|
}) |
|
|
|
.on('complete', function() { |
|
|
|
console.log('Done'); |
|
|
|
console.log('----------------------------------------------------------------------'); |
|
|
|
next(); |
|
|
|
}) |
|
|
|
.run(); |
|
|
|
}, |
|
|
|
function(next) { |
|
|
|
|
|
|
|
var block1; |
|
|
|