summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/net
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/benchmark/net')
-rw-r--r--deps/node/benchmark/net/net-c2s-cork.js85
-rw-r--r--deps/node/benchmark/net/net-c2s.js100
-rw-r--r--deps/node/benchmark/net/net-pipe.js103
-rw-r--r--deps/node/benchmark/net/net-s2c.js101
-rw-r--r--deps/node/benchmark/net/net-wrap-js-stream-passthrough.js96
-rw-r--r--deps/node/benchmark/net/tcp-raw-c2s.js130
-rw-r--r--deps/node/benchmark/net/tcp-raw-pipe.js145
-rw-r--r--deps/node/benchmark/net/tcp-raw-s2c.js135
8 files changed, 0 insertions, 895 deletions
diff --git a/deps/node/benchmark/net/net-c2s-cork.js b/deps/node/benchmark/net/net-c2s-cork.js
deleted file mode 100644
index 34c4b502..00000000
--- a/deps/node/benchmark/net/net-c2s-cork.js
+++ /dev/null
@@ -1,85 +0,0 @@
-// Test the speed of .pipe() with sockets
-'use strict';
-
-const common = require('../common.js');
-const net = require('net');
-const PORT = common.PORT;
-
-const bench = common.createBenchmark(main, {
- len: [4, 8, 16, 32, 64, 128, 512, 1024],
- type: ['buf'],
- dur: [5],
-});
-
-var chunk;
-var encoding;
-
-function main({ dur, len, type }) {
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- encoding = 'utf8';
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- encoding = 'ascii';
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const writer = new Writer();
-
- // the actual benchmark.
- const server = net.createServer((socket) => {
- socket.pipe(writer);
- });
-
- server.listen(PORT, () => {
- const socket = net.connect(PORT);
- socket.on('connect', () => {
- bench.start();
-
- socket.on('drain', send);
- send();
-
- setTimeout(() => {
- const bytes = writer.received;
- const gbits = (bytes * 8) / (1024 * 1024 * 1024);
- bench.end(gbits);
- process.exit(0);
- }, dur * 1000);
-
- function send() {
- socket.cork();
- while (socket.write(chunk, encoding)) {}
- socket.uncork();
- }
- });
- });
-}
-
-function Writer() {
- this.received = 0;
- this.writable = true;
-}
-
-Writer.prototype.write = function(chunk, encoding, cb) {
- this.received += chunk.length;
-
- if (typeof encoding === 'function')
- encoding();
- else if (typeof cb === 'function')
- cb();
-
- return true;
-};
-
-// Doesn't matter, never emits anything.
-Writer.prototype.on = function() {};
-Writer.prototype.once = function() {};
-Writer.prototype.emit = function() {};
-Writer.prototype.prependListener = function() {};
diff --git a/deps/node/benchmark/net/net-c2s.js b/deps/node/benchmark/net/net-c2s.js
deleted file mode 100644
index 732bda13..00000000
--- a/deps/node/benchmark/net/net-c2s.js
+++ /dev/null
@@ -1,100 +0,0 @@
-// Test the speed of .pipe() with sockets
-'use strict';
-
-const common = require('../common.js');
-const net = require('net');
-const PORT = common.PORT;
-
-const bench = common.createBenchmark(main, {
- len: [64, 102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5],
-});
-
-var chunk;
-var encoding;
-
-function main({ dur, len, type }) {
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- encoding = 'utf8';
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- encoding = 'ascii';
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const reader = new Reader();
- const writer = new Writer();
-
- // the actual benchmark.
- const server = net.createServer((socket) => {
- socket.pipe(writer);
- });
-
- server.listen(PORT, () => {
- const socket = net.connect(PORT);
- socket.on('connect', () => {
- bench.start();
-
- reader.pipe(socket);
-
- setTimeout(() => {
- const bytes = writer.received;
- const gbits = (bytes * 8) / (1024 * 1024 * 1024);
- bench.end(gbits);
- process.exit(0);
- }, dur * 1000);
- });
- });
-}
-
-function Writer() {
- this.received = 0;
- this.writable = true;
-}
-
-Writer.prototype.write = function(chunk, encoding, cb) {
- this.received += chunk.length;
-
- if (typeof encoding === 'function')
- encoding();
- else if (typeof cb === 'function')
- cb();
-
- return true;
-};
-
-// Doesn't matter, never emits anything.
-Writer.prototype.on = function() {};
-Writer.prototype.once = function() {};
-Writer.prototype.emit = function() {};
-Writer.prototype.prependListener = function() {};
-
-
-function flow() {
- const dest = this.dest;
- const res = dest.write(chunk, encoding);
- if (!res)
- dest.once('drain', this.flow);
- else
- process.nextTick(this.flow);
-}
-
-function Reader() {
- this.flow = flow.bind(this);
- this.readable = true;
-}
-
-Reader.prototype.pipe = function(dest) {
- this.dest = dest;
- this.flow();
- return dest;
-};
diff --git a/deps/node/benchmark/net/net-pipe.js b/deps/node/benchmark/net/net-pipe.js
deleted file mode 100644
index 12db1e13..00000000
--- a/deps/node/benchmark/net/net-pipe.js
+++ /dev/null
@@ -1,103 +0,0 @@
-// Test the speed of .pipe() with sockets
-'use strict';
-
-const common = require('../common.js');
-const net = require('net');
-const PORT = common.PORT;
-
-const bench = common.createBenchmark(main, {
- len: [64, 102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5],
-});
-
-var chunk;
-var encoding;
-
-function main({ dur, len, type }) {
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- encoding = 'utf8';
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- encoding = 'ascii';
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const reader = new Reader();
- const writer = new Writer();
-
- // the actual benchmark.
- const server = net.createServer((socket) => {
- socket.pipe(socket);
- });
-
- server.listen(PORT, () => {
- const socket = net.connect(PORT);
- socket.on('connect', () => {
- bench.start();
-
- reader.pipe(socket);
- socket.pipe(writer);
-
- setTimeout(() => {
- // Multiply by 2 since we're sending it first one way
- // then then back again.
- const bytes = writer.received * 2;
- const gbits = (bytes * 8) / (1024 * 1024 * 1024);
- bench.end(gbits);
- process.exit(0);
- }, dur * 1000);
- });
- });
-}
-
-function Writer() {
- this.received = 0;
- this.writable = true;
-}
-
-Writer.prototype.write = function(chunk, encoding, cb) {
- this.received += chunk.length;
-
- if (typeof encoding === 'function')
- encoding();
- else if (typeof cb === 'function')
- cb();
-
- return true;
-};
-
-// Doesn't matter, never emits anything.
-Writer.prototype.on = function() {};
-Writer.prototype.once = function() {};
-Writer.prototype.emit = function() {};
-Writer.prototype.prependListener = function() {};
-
-
-function flow() {
- const dest = this.dest;
- const res = dest.write(chunk, encoding);
- if (!res)
- dest.once('drain', this.flow);
- else
- process.nextTick(this.flow);
-}
-
-function Reader() {
- this.flow = flow.bind(this);
- this.readable = true;
-}
-
-Reader.prototype.pipe = function(dest) {
- this.dest = dest;
- this.flow();
- return dest;
-};
diff --git a/deps/node/benchmark/net/net-s2c.js b/deps/node/benchmark/net/net-s2c.js
deleted file mode 100644
index 848168cd..00000000
--- a/deps/node/benchmark/net/net-s2c.js
+++ /dev/null
@@ -1,101 +0,0 @@
-// Test the speed of .pipe() with sockets
-'use strict';
-
-const common = require('../common.js');
-const PORT = common.PORT;
-
-const bench = common.createBenchmark(main, {
- len: [64, 102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5]
-});
-
-var chunk;
-var encoding;
-
-function main({ dur, len, type }) {
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- encoding = 'utf8';
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- encoding = 'ascii';
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const reader = new Reader();
- const writer = new Writer();
-
- // the actual benchmark.
- const server = net.createServer((socket) => {
- reader.pipe(socket);
- });
-
- server.listen(PORT, () => {
- const socket = net.connect(PORT);
- socket.on('connect', () => {
- bench.start();
-
- socket.pipe(writer);
-
- setTimeout(() => {
- const bytes = writer.received;
- const gbits = (bytes * 8) / (1024 * 1024 * 1024);
- bench.end(gbits);
- process.exit(0);
- }, dur * 1000);
- });
- });
-}
-
-const net = require('net');
-
-function Writer() {
- this.received = 0;
- this.writable = true;
-}
-
-Writer.prototype.write = function(chunk, encoding, cb) {
- this.received += chunk.length;
-
- if (typeof encoding === 'function')
- encoding();
- else if (typeof cb === 'function')
- cb();
-
- return true;
-};
-
-// Doesn't matter, never emits anything.
-Writer.prototype.on = function() {};
-Writer.prototype.once = function() {};
-Writer.prototype.emit = function() {};
-Writer.prototype.prependListener = function() {};
-
-
-function flow() {
- const dest = this.dest;
- const res = dest.write(chunk, encoding);
- if (!res)
- dest.once('drain', this.flow);
- else
- process.nextTick(this.flow);
-}
-
-function Reader() {
- this.flow = flow.bind(this);
- this.readable = true;
-}
-
-Reader.prototype.pipe = function(dest) {
- this.dest = dest;
- this.flow();
- return dest;
-};
diff --git a/deps/node/benchmark/net/net-wrap-js-stream-passthrough.js b/deps/node/benchmark/net/net-wrap-js-stream-passthrough.js
deleted file mode 100644
index 1c597b6e..00000000
--- a/deps/node/benchmark/net/net-wrap-js-stream-passthrough.js
+++ /dev/null
@@ -1,96 +0,0 @@
-// Test the speed of .pipe() with JSStream wrapping for PassThrough streams
-'use strict';
-
-const common = require('../common.js');
-const { PassThrough } = require('stream');
-
-const bench = common.createBenchmark(main, {
- len: [64, 102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5],
-}, {
- flags: ['--expose-internals']
-});
-
-var chunk;
-var encoding;
-
-function main({ dur, len, type }) {
- // Can only require internals inside main().
- const JSStreamWrap = require('internal/js_stream_socket');
-
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- encoding = 'utf8';
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- encoding = 'ascii';
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const reader = new Reader();
- const writer = new Writer();
-
- // the actual benchmark.
- const fakeSocket = new JSStreamWrap(new PassThrough());
- bench.start();
- reader.pipe(fakeSocket);
- fakeSocket.pipe(writer);
-
- setTimeout(() => {
- const bytes = writer.received;
- const gbits = (bytes * 8) / (1024 * 1024 * 1024);
- bench.end(gbits);
- process.exit(0);
- }, dur * 1000);
-}
-
-function Writer() {
- this.received = 0;
- this.writable = true;
-}
-
-Writer.prototype.write = function(chunk, encoding, cb) {
- this.received += chunk.length;
-
- if (typeof encoding === 'function')
- encoding();
- else if (typeof cb === 'function')
- cb();
-
- return true;
-};
-
-// Doesn't matter, never emits anything.
-Writer.prototype.on = function() {};
-Writer.prototype.once = function() {};
-Writer.prototype.emit = function() {};
-Writer.prototype.prependListener = function() {};
-
-
-function flow() {
- const dest = this.dest;
- const res = dest.write(chunk, encoding);
- if (!res)
- dest.once('drain', this.flow);
- else
- process.nextTick(this.flow);
-}
-
-function Reader() {
- this.flow = flow.bind(this);
- this.readable = true;
-}
-
-Reader.prototype.pipe = function(dest) {
- this.dest = dest;
- this.flow();
- return dest;
-};
diff --git a/deps/node/benchmark/net/tcp-raw-c2s.js b/deps/node/benchmark/net/tcp-raw-c2s.js
deleted file mode 100644
index fe320dda..00000000
--- a/deps/node/benchmark/net/tcp-raw-c2s.js
+++ /dev/null
@@ -1,130 +0,0 @@
-// In this benchmark, we connect a client to the server, and write
-// as many bytes as we can in the specified time (default = 10s)
-'use strict';
-
-const common = require('../common.js');
-const util = require('util');
-
-// If there are --dur=N and --len=N args, then
-// run the function with those settings.
-// if not, then queue up a bunch of child processes.
-const bench = common.createBenchmark(main, {
- len: [102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5]
-}, { flags: [ '--expose-internals', '--no-warnings' ] });
-
-function main({ dur, len, type }) {
- 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);
- var err = serverHandle.bind('127.0.0.1', PORT);
- if (err)
- fail(err, 'bind');
-
- err = serverHandle.listen(511);
- if (err)
- fail(err, 'listen');
-
- serverHandle.onconnection = function(err, clientHandle) {
- if (err)
- fail(err, 'connect');
-
- // The meat of the benchmark is right here:
- bench.start();
- var bytes = 0;
-
- setTimeout(() => {
- // report in Gb/sec
- bench.end((bytes * 8) / (1024 * 1024 * 1024));
- process.exit(0);
- }, dur * 1000);
-
- clientHandle.onread = function(buffer) {
- // We're not expecting to ever get an EOF from the client.
- // Just lots of data forever.
- if (!buffer)
- fail('read');
-
- // Don't slice the buffer. The point of this is to isolate, not
- // simulate real traffic.
- bytes += buffer.byteLength;
- };
-
- clientHandle.readStart();
- };
-
- client(type, len);
-
- function fail(err, syscall) {
- throw util._errnoException(err, syscall);
- }
-
- function client(type, len) {
- var chunk;
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const clientHandle = new TCP(TCPConstants.SOCKET);
- const connectReq = new TCPConnectWrap();
- const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
-
- if (err)
- fail(err, 'connect');
-
- clientHandle.readStart();
-
- connectReq.oncomplete = function(err) {
- if (err)
- fail(err, 'connect');
-
- while (clientHandle.writeQueueSize === 0)
- write();
- };
-
- function write() {
- const writeReq = new WriteWrap();
- writeReq.oncomplete = afterWrite;
- var err;
- switch (type) {
- case 'buf':
- err = clientHandle.writeBuffer(writeReq, chunk);
- break;
- case 'utf':
- err = clientHandle.writeUtf8String(writeReq, chunk);
- break;
- case 'asc':
- err = clientHandle.writeAsciiString(writeReq, chunk);
- break;
- }
-
- if (err)
- fail(err, 'write');
- }
-
- function afterWrite(err, handle) {
- if (err)
- fail(err, 'write');
-
- while (clientHandle.writeQueueSize === 0)
- write();
- }
- }
-}
diff --git a/deps/node/benchmark/net/tcp-raw-pipe.js b/deps/node/benchmark/net/tcp-raw-pipe.js
deleted file mode 100644
index 89db42dc..00000000
--- a/deps/node/benchmark/net/tcp-raw-pipe.js
+++ /dev/null
@@ -1,145 +0,0 @@
-// In this benchmark, we connect a client to the server, and write
-// as many bytes as we can in the specified time (default = 10s)
-'use strict';
-
-const common = require('../common.js');
-const util = require('util');
-
-// If there are --dur=N and --len=N args, then
-// run the function with those settings.
-// if not, then queue up a bunch of child processes.
-const bench = common.createBenchmark(main, {
- len: [102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5]
-}, {
- flags: [ '--expose-internals', '--no-warnings' ]
-});
-
-function main({ dur, len, type }) {
- const {
- TCP,
- TCPConnectWrap,
- constants: TCPConstants
- } = common.binding('tcp_wrap');
- const { WriteWrap } = common.binding('stream_wrap');
- const PORT = common.PORT;
-
- function fail(err, syscall) {
- throw util._errnoException(err, syscall);
- }
-
- // Server
- const serverHandle = new TCP(TCPConstants.SERVER);
- var err = serverHandle.bind('127.0.0.1', PORT);
- if (err)
- fail(err, 'bind');
-
- err = serverHandle.listen(511);
- if (err)
- fail(err, 'listen');
-
- serverHandle.onconnection = function(err, clientHandle) {
- if (err)
- fail(err, 'connect');
-
- clientHandle.onread = function(buffer) {
- // We're not expecting to ever get an EOF from the client.
- // Just lots of data forever.
- if (!buffer)
- fail('read');
-
- const writeReq = new WriteWrap();
- writeReq.async = false;
- err = clientHandle.writeBuffer(writeReq, Buffer.from(buffer));
-
- if (err)
- fail(err, 'write');
-
- writeReq.oncomplete = function(status, handle, err) {
- if (err)
- fail(err, 'write');
- };
- };
-
- clientHandle.readStart();
- };
-
- // Client
- var chunk;
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- const clientHandle = new TCP(TCPConstants.SOCKET);
- const connectReq = new TCPConnectWrap();
- var bytes = 0;
-
- err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
- if (err)
- fail(err, 'connect');
-
- clientHandle.onread = function(buffer) {
- if (!buffer)
- fail('read');
-
- bytes += buffer.byteLength;
- };
-
- connectReq.oncomplete = function(err) {
- if (err)
- fail(err, 'connect');
-
- bench.start();
-
- clientHandle.readStart();
-
- setTimeout(() => {
- // Multiply by 2 since we're sending it first one way
- // then then back again.
- bench.end(2 * (bytes * 8) / (1024 * 1024 * 1024));
- process.exit(0);
- }, dur * 1000);
-
- while (clientHandle.writeQueueSize === 0)
- write();
- };
-
- function write() {
- const writeReq = new WriteWrap();
- writeReq.oncomplete = afterWrite;
- var err;
- switch (type) {
- case 'buf':
- err = clientHandle.writeBuffer(writeReq, chunk);
- break;
- case 'utf':
- err = clientHandle.writeUtf8String(writeReq, chunk);
- break;
- case 'asc':
- err = clientHandle.writeAsciiString(writeReq, chunk);
- break;
- }
-
- if (err)
- fail(err, 'write');
- }
-
- function afterWrite(err, handle) {
- if (err)
- fail(err, 'write');
-
- while (clientHandle.writeQueueSize === 0)
- write();
- }
-}
diff --git a/deps/node/benchmark/net/tcp-raw-s2c.js b/deps/node/benchmark/net/tcp-raw-s2c.js
deleted file mode 100644
index cc2f6901..00000000
--- a/deps/node/benchmark/net/tcp-raw-s2c.js
+++ /dev/null
@@ -1,135 +0,0 @@
-// In this benchmark, we connect a client to the server, and write
-// as many bytes as we can in the specified time (default = 10s)
-'use strict';
-
-const common = require('../common.js');
-const util = require('util');
-
-// If there are dur=N and len=N args, then
-// run the function with those settings.
-// If not, then queue up a bunch of child processes.
-const bench = common.createBenchmark(main, {
- len: [102400, 1024 * 1024 * 16],
- type: ['utf', 'asc', 'buf'],
- dur: [5]
-}, {
- flags: [ '--expose-internals', '--no-warnings' ]
-});
-
-function main({ dur, len, type }) {
- 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);
- var err = serverHandle.bind('127.0.0.1', PORT);
- if (err)
- fail(err, 'bind');
-
- err = serverHandle.listen(511);
- if (err)
- fail(err, 'listen');
-
- serverHandle.onconnection = function(err, clientHandle) {
- if (err)
- fail(err, 'connect');
-
- var chunk;
- switch (type) {
- case 'buf':
- chunk = Buffer.alloc(len, 'x');
- break;
- case 'utf':
- chunk = 'ü'.repeat(len / 2);
- break;
- case 'asc':
- chunk = 'x'.repeat(len);
- break;
- default:
- throw new Error(`invalid type: ${type}`);
- }
-
- clientHandle.readStart();
-
- while (clientHandle.writeQueueSize === 0)
- write();
-
- function write() {
- const writeReq = new WriteWrap();
- writeReq.async = false;
- writeReq.oncomplete = afterWrite;
- var err;
- switch (type) {
- case 'buf':
- err = clientHandle.writeBuffer(writeReq, chunk);
- break;
- case 'utf':
- err = clientHandle.writeUtf8String(writeReq, chunk);
- break;
- case 'asc':
- err = clientHandle.writeAsciiString(writeReq, chunk);
- break;
- }
-
- if (err) {
- fail(err, 'write');
- } else if (!writeReq.async) {
- process.nextTick(() => {
- afterWrite(0, clientHandle);
- });
- }
- }
-
- function afterWrite(status, handle) {
- if (status)
- fail(status, 'write');
-
- while (clientHandle.writeQueueSize === 0)
- write();
- }
- };
-
- client(dur);
-
- function fail(err, syscall) {
- throw util._errnoException(err, syscall);
- }
-
- function client(dur) {
- const clientHandle = new TCP(TCPConstants.SOCKET);
- const connectReq = new TCPConnectWrap();
- const err = clientHandle.connect(connectReq, '127.0.0.1', PORT);
-
- if (err)
- fail(err, 'connect');
-
- connectReq.oncomplete = function() {
- var bytes = 0;
- clientHandle.onread = function(buffer) {
- // We're not expecting to ever get an EOF from the client.
- // Just lots of data forever.
- if (!buffer)
- fail('read');
-
- // Don't slice the buffer. The point of this is to isolate, not
- // simulate real traffic.
- bytes += buffer.byteLength;
- };
-
- clientHandle.readStart();
-
- // The meat of the benchmark is right here:
- bench.start();
-
- setTimeout(() => {
- // report in Gb/sec
- bench.end((bytes * 8) / (1024 * 1024 * 1024));
- process.exit(0);
- }, dur * 1000);
- };
- }
-}