You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
typesetting/pitfall/pdfkit/node_modules/buffer/perf/solo/readUInt32LE.js

27 lines
591 B
JavaScript

7 years ago
var benchmark = require('benchmark')
var suite = new benchmark.Suite()
global.NewBuffer = require('../../').Buffer // native-buffer-browserify
var LENGTH = 20
var newTarget = NewBuffer(LENGTH * 4)
for (var i = 0; i < LENGTH; i++) {
newTarget.writeUInt32LE(7000 + i, i * 4)
}
suite.add('NewBuffer#readUInt32LE', function () {
for (var i = 0; i < LENGTH; i++) {
var x = newTarget.readUInt32LE(i * 4)
}
})
.on('error', function (event) {
console.error(event.target.error.stack)
})
.on('cycle', function (event) {
console.log(String(event.target))
})
.run({ 'async': true })