Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
meta: merge node/master into node-chakracore/master
Browse files Browse the repository at this point in the history
Merge 5a55a71 as of 2018-03-03
This commit was automatically generated. For any problems, please contact jackhorton

Reviewed-By: Jack Horton <jahorto@microsoft.com>
  • Loading branch information
chakrabot committed Mar 5, 2018
2 parents c48e29d + 5a55a71 commit 38d2724
Show file tree
Hide file tree
Showing 60 changed files with 2,771 additions and 2,354 deletions.
31 changes: 31 additions & 0 deletions benchmark/buffers/buffer-fill.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
'use strict';
const common = require('../common.js');

const bench = common.createBenchmark(main, {
type: [
'fill(0)',
'fill("")',
'fill(100)',
'fill(400)',
'fill("t")',
'fill("test")',
'fill("t", "utf8")',
'fill("t", 0, "utf8")',
'fill("t", 0)',
'fill(Buffer.alloc(1), 0)'
],
size: [2 ** 8, 2 ** 13, 2 ** 16],
n: [2e4]
});

function main({ n, type, size }) {
const buffer = Buffer.allocUnsafe(size);
const testFunction = new Function('b', `
for (var i = 0; i < ${n}; i++) {
b.${type || 'fill(0)'};
}
`);
bench.start();
testFunction(buffer);
bench.end(n);
}
43 changes: 43 additions & 0 deletions benchmark/buffers/buffer-normalize-encoding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
encoding: [
'ascii',
'ASCII',
'base64',
'BASE64',
'binary',
'BINARY',
'hex',
'HEX',
'latin1',
'LATIN1',
'ucs-2',
'UCS-2',
'ucs2',
'UCS2',
'utf-16le',
'UTF-16LE',
'utf-8',
'UTF-8',
'utf16le',
'UTF16LE',
'utf8',
'UTF8'
],
n: [1e6]
}, {
flags: ['--expose-internals']
});

function main({ encoding, n }) {
const { normalizeEncoding } = require('internal/util');

bench.start();
for (var i = 0; i < n; i++) {
normalizeEncoding(encoding);
}
bench.end(n);
}
8 changes: 3 additions & 5 deletions benchmark/buffers/buffer-read-float.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,13 @@
const common = require('../common.js');

const bench = common.createBenchmark(main, {
noAssert: ['false', 'true'],
type: ['Double', 'Float'],
endian: ['BE', 'LE'],
value: ['zero', 'big', 'small', 'inf', 'nan'],
millions: [1]
});

function main({ noAssert, millions, type, endian, value }) {
noAssert = noAssert === 'true';
function main({ millions, type, endian, value }) {
type = type || 'Double';
const buff = Buffer.alloc(8);
const fn = `read${type}${endian}`;
Expand All @@ -31,11 +29,11 @@ function main({ noAssert, millions, type, endian, value }) {
},
};

buff[`write${type}${endian}`](values[type][value], 0, noAssert);
buff[`write${type}${endian}`](values[type][value], 0);

bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](0, noAssert);
buff[fn](0);
}
bench.end(millions);
}
13 changes: 5 additions & 8 deletions benchmark/buffers/buffer-read-with-byteLength.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,21 @@ const types = [
];

const bench = common.createBenchmark(main, {
noAssert: ['false', 'true'],
buffer: ['fast', 'slow'],
type: types,
millions: [1],
byteLength: [1, 2, 4, 6]
byteLength: [1, 2, 3, 4, 5, 6]
});

function main({ millions, noAssert, buf, type, byteLength }) {
noAssert = noAssert === 'true';
type = type || 'UInt8';
function main({ millions, buf, type, byteLength }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `read${type}`;
const fn = `read${type || 'IntBE'}`;

buff.writeDoubleLE(0, 0, noAssert);
buff.writeDoubleLE(0, 0);
bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](0, byteLength, noAssert);
buff[fn](0, byteLength);
}
bench.end(millions);
}
8 changes: 3 additions & 5 deletions benchmark/buffers/buffer-read.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,20 @@ const types = [
];

const bench = common.createBenchmark(main, {
noAssert: ['false', 'true'],
buffer: ['fast', 'slow'],
type: types,
millions: [1]
});

function main({ noAssert, millions, buf, type }) {
noAssert = noAssert === 'true';
function main({ millions, buf, type }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `read${type || 'UInt8'}`;

buff.writeDoubleLE(0, 0, noAssert);
buff.writeDoubleLE(0, 0);
bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](0, noAssert);
buff[fn](0);
}
bench.end(millions);
}
54 changes: 40 additions & 14 deletions benchmark/buffers/buffer-write.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,22 @@ const types = [
'UInt16BE',
'UInt32LE',
'UInt32BE',
'UIntLE',
'UIntBE',
'Int8',
'Int16LE',
'Int16BE',
'Int32LE',
'Int32BE',
'IntLE',
'IntBE',
'FloatLE',
'FloatBE',
'DoubleLE',
'DoubleBE'
];

const bench = common.createBenchmark(main, {
noAssert: ['false', 'true'],
buffer: ['fast', 'slow'],
type: types,
millions: [1]
Expand All @@ -28,9 +31,9 @@ const bench = common.createBenchmark(main, {
const INT8 = 0x7f;
const INT16 = 0x7fff;
const INT32 = 0x7fffffff;
const UINT8 = (INT8 * 2) + 1;
const UINT16 = (INT16 * 2) + 1;
const UINT32 = INT32;
const INT48 = 0x7fffffffffff;
const UINT8 = 0xff;
const UINT16 = 0xffff;

const mod = {
writeInt8: INT8,
Expand All @@ -41,34 +44,57 @@ const mod = {
writeUInt8: UINT8,
writeUInt16BE: UINT16,
writeUInt16LE: UINT16,
writeUInt32BE: UINT32,
writeUInt32LE: UINT32
writeUInt32BE: INT32,
writeUInt32LE: INT32,
writeUIntLE: INT8,
writeUIntBE: INT16,
writeIntLE: INT32,
writeIntBE: INT48
};

function main({ noAssert, millions, buf, type }) {
const byteLength = {
writeUIntLE: 1,
writeUIntBE: 2,
writeIntLE: 4,
writeIntBE: 6
};

function main({ millions, buf, type }) {
const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer;
const buff = new clazz(8);
const fn = `write${type || 'UInt8'}`;

if (/Int/.test(fn))
benchInt(buff, fn, millions, noAssert);
if (!/\d/.test(fn))
benchSpecialInt(buff, fn, millions);
else if (/Int/.test(fn))
benchInt(buff, fn, millions);
else
benchFloat(buff, fn, millions, noAssert);
benchFloat(buff, fn, millions);
}

function benchInt(buff, fn, millions) {
const m = mod[fn];
bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](i & m, 0);
}
bench.end(millions);
}

function benchInt(buff, fn, millions, noAssert) {
function benchSpecialInt(buff, fn, millions) {
const m = mod[fn];
const byte = byteLength[fn];
bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](i & m, 0, noAssert);
buff[fn](i & m, 0, byte);
}
bench.end(millions);
}

function benchFloat(buff, fn, millions, noAssert) {
function benchFloat(buff, fn, millions) {
bench.start();
for (var i = 0; i !== millions * 1e6; i++) {
buff[fn](i, 0, noAssert);
buff[fn](i, 0);
}
bench.end(millions);
}
File renamed without changes.
5 changes: 3 additions & 2 deletions doc/api/addons.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ involving knowledge of several components and APIs :

- Node.js includes a number of other statically linked libraries including
OpenSSL. These other libraries are located in the `deps/` directory in the
Node.js source tree. Only the V8 and OpenSSL symbols are purposefully
re-exported by Node.js and may be used to various extents by Addons.
Node.js source tree. Only the libuv, OpenSSL, V8 and zlib symbols are
purposefully re-exported by Node.js and may be used to various extents by
Addons.
See [Linking to Node.js' own dependencies][] for additional information.

All of the following examples are available for [download][] and may
Expand Down
Loading

0 comments on commit 38d2724

Please sign in to comment.