mirror of
https://github.com/nodejs/node.git
synced 2026-10-14 10:26:26 -04:00
Several changes:
* Soft-Deprecate Buffer() constructors
* Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`
* Add `--zero-fill-buffers` command line option
* Add byteOffset and length to `new Buffer(arrayBuffer)` constructor
* buffer.fill('') previously had no effect, now zero-fills
* Update the docs
PR-URL: https://github.com/nodejs/node/pull/4682
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
19 lines
291 B
JavaScript
19 lines
291 B
JavaScript
'use strict';
|
|
|
|
const common = require('../common.js');
|
|
|
|
const bench = common.createBenchmark(main, {
|
|
n: [1024]
|
|
});
|
|
|
|
const zero = Buffer.alloc(0);
|
|
|
|
function main(conf) {
|
|
var n = +conf.n;
|
|
bench.start();
|
|
for (let i = 0; i < n * 1024; i++) {
|
|
Buffer.from(zero);
|
|
}
|
|
bench.end(n);
|
|
}
|