Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions benchmark/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,13 @@ Benchmark.prototype.report = function(rate, elapsed) {
type: 'report'
});
};

exports.binding = function(bindingName) {
try {
const { internalBinding } = require('internal/test/binding');

return internalBinding(bindingName);
} catch {
return process.binding(bindingName);
}
};
3 changes: 1 addition & 2 deletions benchmark/http/bench-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ const bench = common.createBenchmark(main, {
});

function main({ len, n }) {
const { internalBinding } = require('internal/test/binding');
const { HTTPParser } = internalBinding('http_parser');
const { HTTPParser } = common.binding('http_parser');
const REQUEST = HTTPParser.REQUEST;
const kOnHeaders = HTTPParser.kOnHeaders | 0;
const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0;
Expand Down
2 changes: 1 addition & 1 deletion benchmark/misc/punycode.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const common = require('../common.js');
let icu;
try {
icu = process.binding('icu');
icu = common.binding('icu');
} catch (err) {}
const punycode = require('punycode');

Expand Down
6 changes: 2 additions & 4 deletions benchmark/misc/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const bench = common.createBenchmark(main, {

const {
TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN: kBeforeEvent
} = process.binding('constants').trace;
} = common.binding('constants').trace;

function doTrace(n, trace) {
bench.start();
Expand All @@ -31,12 +31,10 @@ function doIsTraceCategoryEnabled(n, isTraceCategoryEnabled) {
}

function main({ n, method }) {
const { internalBinding } = require('internal/test/binding');

const {
trace,
isTraceCategoryEnabled
} = internalBinding('trace_events');
} = common.binding('trace_events');

switch (method) {
case '':
Expand Down
10 changes: 6 additions & 4 deletions benchmark/net/tcp-raw-c2s.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ const bench = common.createBenchmark(main, {
}, { flags: [ '--expose-internals', '--no-warnings' ] });

function main({ dur, len, type }) {
const { internalBinding } = require('internal/test/binding');
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const { TCPConnectWrap } = process.binding('tcp_wrap');
const { WriteWrap } = internalBinding('stream_wrap');
const {
TCP,
TCPConnectWrap,
constants: TCPConstants
} = common.binding('tcp_wrap');
const { WriteWrap } = common.binding('stream_wrap');
const PORT = common.PORT;

const serverHandle = new TCP(TCPConstants.SERVER);
Expand Down
10 changes: 6 additions & 4 deletions benchmark/net/tcp-raw-pipe.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const bench = common.createBenchmark(main, {
});

function main({ dur, len, type }) {
const { internalBinding } = require('internal/test/binding');
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const { TCPConnectWrap } = process.binding('tcp_wrap');
const { WriteWrap } = internalBinding('stream_wrap');
const {
TCP,
TCPConnectWrap,
constants: TCPConstants
} = common.binding('tcp_wrap');
const { WriteWrap } = common.binding('stream_wrap');
const PORT = common.PORT;

function fail(err, syscall) {
Expand Down
10 changes: 6 additions & 4 deletions benchmark/net/tcp-raw-s2c.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const bench = common.createBenchmark(main, {
});

function main({ dur, len, type }) {
const { internalBinding } = require('internal/test/binding');
const { TCP, constants: TCPConstants } = process.binding('tcp_wrap');
const { TCPConnectWrap } = process.binding('tcp_wrap');
const { WriteWrap } = internalBinding('stream_wrap');
const {
TCP,
TCPConnectWrap,
constants: TCPConstants
} = common.binding('tcp_wrap');
const { WriteWrap } = common.binding('stream_wrap');
const PORT = common.PORT;

const serverHandle = new TCP(TCPConstants.SERVER);
Expand Down
3 changes: 1 addition & 2 deletions benchmark/util/type-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,7 @@ function main({ type, argument, version, n }) {
// For testing, if supplied with an empty type, default to ArrayBufferView.
type = type || 'ArrayBufferView';

const { internalBinding } = require('internal/test/binding');
const util = internalBinding('util');
const util = common.binding('util');
const types = require('internal/util/types');

const func = { native: util, js: types }[version][`is${type}`];
Expand Down