diff options
Diffstat (limited to 'deps/node/benchmark')
243 files changed, 0 insertions, 15866 deletions
diff --git a/deps/node/benchmark/.eslintrc.yaml b/deps/node/benchmark/.eslintrc.yaml deleted file mode 100644 index f8585fd7..00000000 --- a/deps/node/benchmark/.eslintrc.yaml +++ /dev/null @@ -1,10 +0,0 @@ -## Benchmark-specific linter rules - -rules: - comma-dangle: - - error - - arrays: 'always-multiline' - objects: 'only-multiline' - imports: 'only-multiline' - exports: 'only-multiline' - prefer-arrow-callback: error diff --git a/deps/node/benchmark/README.md b/deps/node/benchmark/README.md deleted file mode 100644 index 8b30ab87..00000000 --- a/deps/node/benchmark/README.md +++ /dev/null @@ -1,98 +0,0 @@ -# Node.js Core Benchmarks - -This folder contains code and data used to measure performance -of different Node.js implementations and different ways of -writing JavaScript run by the built-in JavaScript engine. - -For a detailed guide on how to write and run benchmarks in this -directory, see [the guide on benchmarks](../doc/guides/writing-and-running-benchmarks.md). - -## Table of Contents - -* [Benchmark directories](#benchmark-directories) -* [Common API](#common-api) - -## Benchmark Directories - -| Directory | Purpose | -| --------------- | ---------------------------------------------------------------------------------------------------------------- | -| assert | Benchmarks for the `assert` subsystem. | -| buffers | Benchmarks for the `buffer` subsystem. | -| child\_process | Benchmarks for the `child_process` subsystem. | -| crypto | Benchmarks for the `crypto` subsystem. | -| dgram | Benchmarks for the `dgram` subsystem. | -| domain | Benchmarks for the `domain` subsystem. | -| es | Benchmarks for various new ECMAScript features and their pre-ES2015 counterparts. | -| events | Benchmarks for the `events` subsystem. | -| fixtures | Benchmarks fixtures used in various benchmarks throughout the benchmark suite. | -| fs | Benchmarks for the `fs` subsystem. | -| http | Benchmarks for the `http` subsystem. | -| http2 | Benchmarks for the `http2` subsystem. | -| misc | Miscellaneous benchmarks and benchmarks for shared internal modules. | -| module | Benchmarks for the `module` subsystem. | -| net | Benchmarks for the `net` subsystem. | -| path | Benchmarks for the `path` subsystem. | -| process | Benchmarks for the `process` subsystem. | -| querystring | Benchmarks for the `querystring` subsystem. | -| streams | Benchmarks for the `streams` subsystem. | -| string\_decoder | Benchmarks for the `string_decoder` subsystem. | -| timers | Benchmarks for the `timers` subsystem, including `setTimeout`, `setInterval`, .etc. | -| tls | Benchmarks for the `tls` subsystem. | -| url | Benchmarks for the `url` subsystem, including the legacy `url` implementation and the WHATWG URL implementation. | -| util | Benchmarks for the `util` subsystem. | -| vm | Benchmarks for the `vm` subsystem. | - -### Other Top-level files - -The top-level files include common dependencies of the benchmarks -and the tools for launching benchmarks and visualizing their output. -The actual benchmark scripts should be placed in their corresponding -directories. - -* `_benchmark_progress.js`: implements the progress bar displayed - when running `compare.js` -* `_cli.js`: parses the command line arguments passed to `compare.js`, - `run.js` and `scatter.js` -* `_cli.R`: parses the command line arguments passed to `compare.R` -* `_http-benchmarkers.js`: selects and runs external tools for benchmarking - the `http` subsystem. -* `common.js`: see [Common API](#common-api). -* `compare.js`: command line tool for comparing performance between different - Node.js binaries. -* `compare.R`: R script for statistically analyzing the output of - `compare.js` -* `run.js`: command line tool for running individual benchmark suite(s). -* `scatter.js`: command line tool for comparing the performance - between different parameters in benchmark configurations, - for example to analyze the time complexity. -* `scatter.R`: R script for visualizing the output of `scatter.js` with - scatter plots. - -## Common API - -The common.js module is used by benchmarks for consistency across repeated -tasks. It has a number of helpful functions and properties to help with -writing benchmarks. - -### createBenchmark(fn, configs[, options]) - -See [the guide on writing benchmarks](../doc/guides/writing-and-running-benchmarks.md#basics-of-a-benchmark). - -### default\_http\_benchmarker - -The default benchmarker used to run HTTP benchmarks. -See [the guide on writing HTTP benchmarks](../doc/guides/writing-and-running-benchmarks.md#creating-an-http-benchmark). - - -### PORT - -The default port used to run HTTP benchmarks. -See [the guide on writing HTTP benchmarks](../doc/guides/writing-and-running-benchmarks.md#creating-an-http-benchmark). - -### sendResult(data) - -Used in special benchmarks that can't use `createBenchmark` and the object -it returns to accomplish what they need. This function reports timing -data to the parent process (usually created by running `compare.js`, `run.js` or -`scatter.js`). - diff --git a/deps/node/benchmark/_benchmark_progress.js b/deps/node/benchmark/_benchmark_progress.js deleted file mode 100644 index 935b1f24..00000000 --- a/deps/node/benchmark/_benchmark_progress.js +++ /dev/null @@ -1,121 +0,0 @@ -'use strict'; - -const readline = require('readline'); - -function pad(input, minLength, fill) { - const result = String(input); - const padding = fill.repeat(Math.max(0, minLength - result.length)); - return `${padding}${result}`; -} - -function fraction(numerator, denominator) { - const fdenominator = String(denominator); - const fnumerator = pad(numerator, fdenominator.length, ' '); - return `${fnumerator}/${fdenominator}`; -} - -function getTime(diff) { - const time = Math.ceil(diff[0] + diff[1] / 1e9); - const hours = pad(Math.floor(time / 3600), 2, '0'); - const minutes = pad(Math.floor((time % 3600) / 60), 2, '0'); - const seconds = pad((time % 3600) % 60, 2, '0'); - return `${hours}:${minutes}:${seconds}`; -} - -// A run is an item in the job queue: { binary, filename, iter } -// A config is an item in the subqueue: { binary, filename, iter, configs } -class BenchmarkProgress { - constructor(queue, benchmarks) { - this.queue = queue; // Scheduled runs. - this.benchmarks = benchmarks; // Filenames of scheduled benchmarks. - this.completedRuns = 0; // Number of completed runs. - this.scheduledRuns = queue.length; // Number of scheduled runs. - // Time when starting to run benchmarks. - this.startTime = process.hrtime(); - // Number of times each file will be run (roughly). - this.runsPerFile = queue.length / benchmarks.length; - this.currentFile = ''; // Filename of current benchmark. - this.currentFileConfig; // Configurations for current file - // Number of configurations already run for the current file. - this.completedConfig = 0; - // Total number of configurations for the current file - this.scheduledConfig = 0; - this.interval; // Updates the elapsed time. - } - - startQueue(index) { - this.kStartOfQueue = index; - this.currentFile = this.queue[index].filename; - this.interval = setInterval(() => { - if (this.completedRuns === this.scheduledRuns) { - clearInterval(this.interval); - } else { - this.updateProgress(); - } - }, 1000); - } - - startSubqueue(data, index) { - // This subqueue is generated by a new benchmark - if (data.name !== this.currentFile || index === this.kStartOfQueue) { - this.currentFile = data.name; - this.scheduledConfig = data.queueLength; - } - this.completedConfig = 0; - this.updateProgress(); - } - - completeConfig() { - this.completedConfig++; - this.updateProgress(); - } - - completeRun() { - this.completedRuns++; - this.updateProgress(); - } - - getProgress() { - // Get time as soon as possible. - const diff = process.hrtime(this.startTime); - - const completedRuns = this.completedRuns; - const scheduledRuns = this.scheduledRuns; - const finished = completedRuns === scheduledRuns; - - // Calculate numbers for fractions. - const runsPerFile = this.runsPerFile; - const completedFiles = Math.floor(completedRuns / runsPerFile); - const scheduledFiles = this.benchmarks.length; - const completedRunsForFile = - finished ? runsPerFile : completedRuns % runsPerFile; - const completedConfig = this.completedConfig; - const scheduledConfig = this.scheduledConfig; - - // Calculate the percentage. - let runRate = 0; // Rate of current incomplete run. - if (completedConfig !== scheduledConfig) { - runRate = completedConfig / scheduledConfig; - } - const completedRate = ((completedRuns + runRate) / scheduledRuns); - const percent = pad(Math.floor(completedRate * 100), 3, ' '); - - const caption = finished ? 'Done\n' : this.currentFile; - return `[${getTime(diff)}|% ${percent}| ` + - `${fraction(completedFiles, scheduledFiles)} files | ` + - `${fraction(completedRunsForFile, runsPerFile)} runs | ` + - `${fraction(completedConfig, scheduledConfig)} configs]: ` + - `${caption} `; - } - - updateProgress() { - if (!process.stderr.isTTY || process.stdout.isTTY) { - return; - } - readline.clearLine(process.stderr); - readline.cursorTo(process.stderr, 0); - process.stderr.write(this.getProgress()); - } -} - -module.exports = BenchmarkProgress; diff --git a/deps/node/benchmark/_cli.R b/deps/node/benchmark/_cli.R deleted file mode 100644 index 522f6565..00000000 --- a/deps/node/benchmark/_cli.R +++ /dev/null @@ -1,24 +0,0 @@ - -args = commandArgs(TRUE); - -args.options = list(); - -temp.option.key = NULL; - -for (arg in args) { - # Optional arguments declaration - if (substring(arg, 1, 1) == '-') { - temp.option.key = substring(arg, 2); - if (substring(arg, 2, 2) == '-') { - temp.option.key = substring(arg, 3); - } - - args.options[[temp.option.key]] = TRUE; - } - # Optional arguments value - else if (!is.null(temp.option.key)) { - args.options[[temp.option.key]] = arg; - - temp.option.key = NULL; - } -} diff --git a/deps/node/benchmark/_cli.js b/deps/node/benchmark/_cli.js deleted file mode 100644 index fa2bfb83..00000000 --- a/deps/node/benchmark/_cli.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -const fs = require('fs'); -const path = require('path'); - -// Create an object of all benchmark scripts -const benchmarks = {}; -fs.readdirSync(__dirname) - .filter((name) => fs.statSync(path.resolve(__dirname, name)).isDirectory()) - .forEach((category) => { - benchmarks[category] = fs.readdirSync(path.resolve(__dirname, category)) - .filter((filename) => filename[0] !== '.' && filename[0] !== '_'); - }); - -function CLI(usage, settings) { - if (!(this instanceof CLI)) return new CLI(usage, settings); - - if (process.argv.length < 3) { - this.abort(usage); // abort will exit the process - } - - this.usage = usage; - this.optional = {}; - this.items = []; - - for (const argName of settings.arrayArgs) { - this.optional[argName] = []; - } - - let currentOptional = null; - let mode = 'both'; // Possible states are: [both, option, item] - - for (const arg of process.argv.slice(2)) { - if (arg === '--') { - // Only items can follow -- - mode = 'item'; - } else if (['both', 'option'].includes(mode) && arg[0] === '-') { - // Optional arguments declaration - - if (arg[1] === '-') { - currentOptional = arg.slice(2); - } else { - currentOptional = arg.slice(1); - } - - if (settings.boolArgs && settings.boolArgs.includes(currentOptional)) { - this.optional[currentOptional] = true; - mode = 'both'; - } else { - // Expect the next value to be option related (either -- or the value) - mode = 'option'; - } - } else if (mode === 'option') { - // Optional arguments value - - if (settings.arrayArgs.includes(currentOptional)) { - this.optional[currentOptional].push(arg); - } else { - this.optional[currentOptional] = arg; - } - - // The next value can be either an option or an item - mode = 'both'; - } else if (['both', 'item'].includes(mode)) { - // item arguments - this.items.push(arg); - - // The next value must be an item - mode = 'item'; - } else { - // Bad case, abort - this.abort(usage); - } - } -} -module.exports = CLI; - -CLI.prototype.abort = function(msg) { - console.error(msg); - process.exit(1); -}; - -CLI.prototype.benchmarks = function() { - const paths = []; - const filter = this.optional.filter || false; - - for (const category of this.items) { - if (benchmarks[category] === undefined) - continue; - for (const scripts of benchmarks[category]) { - if (filter && scripts.lastIndexOf(filter) === -1) continue; - - paths.push(path.join(category, scripts)); - } - } - - return paths; -}; diff --git a/deps/node/benchmark/_http-benchmarkers.js b/deps/node/benchmark/_http-benchmarkers.js deleted file mode 100644 index a4d62300..00000000 --- a/deps/node/benchmark/_http-benchmarkers.js +++ /dev/null @@ -1,243 +0,0 @@ -'use strict'; - -const child_process = require('child_process'); -const path = require('path'); -const fs = require('fs'); - -const requirementsURL = - 'https://github.com/nodejs/node/blob/master/doc/guides/writing-and-running-benchmarks.md#http-benchmark-requirements'; - -// The port used by servers and wrk -exports.PORT = Number(process.env.PORT) || 12346; - -class AutocannonBenchmarker { - constructor() { - this.name = 'autocannon'; - this.executable = - process.platform === 'win32' ? 'autocannon.cmd' : 'autocannon'; - const result = child_process.spawnSync(this.executable, ['-h']); - this.present = !(result.error && result.error.code === 'ENOENT'); - } - - create(options) { - const args = [ - '-d', options.duration, - '-c', options.connections, - '-j', - '-n', - ]; - for (const field in options.headers) { - args.push('-H', `${field}=${options.headers[field]}`); - } - args.push(`http://127.0.0.1:${options.port}${options.path}`); - const child = child_process.spawn(this.executable, args); - return child; - } - - processResults(output) { - let result; - try { - result = JSON.parse(output); - } catch { - return undefined; - } - if (!result || !result.requests || !result.requests.average) { - return undefined; - } else { - return result.requests.average; - } - } -} - -class WrkBenchmarker { - constructor() { - this.name = 'wrk'; - this.executable = 'wrk'; - const result = child_process.spawnSync(this.executable, ['-h']); - this.present = !(result.error && result.error.code === 'ENOENT'); - } - - create(options) { - const args = [ - '-d', options.duration, - '-c', options.connections, - '-t', 8, - `http://127.0.0.1:${options.port}${options.path}`, - ]; - const child = child_process.spawn(this.executable, args); - return child; - } - - processResults(output) { - const throughputRe = /Requests\/sec:[ \t]+([0-9.]+)/; - const match = output.match(throughputRe); - const throughput = match && +match[1]; - if (!isFinite(throughput)) { - return undefined; - } else { - return throughput; - } - } -} - -/** - * Simple, single-threaded benchmarker for testing if the benchmark - * works - */ -class TestDoubleBenchmarker { - constructor(type) { - // `type` is the type ofbenchmarker. Possible values are 'http' and 'http2'. - this.name = `test-double-${type}`; - this.executable = path.resolve(__dirname, '_test-double-benchmarker.js'); - this.present = fs.existsSync(this.executable); - this.type = type; - } - - create(options) { - const env = Object.assign({ - duration: options.duration, - test_url: `http://127.0.0.1:${options.port}${options.path}`, - }, process.env); - - const child = child_process.fork(this.executable, - [this.type], - { silent: true, env }); - return child; - } - - processResults(output) { - let result; - try { - result = JSON.parse(output); - } catch { - return undefined; - } - return result.throughput; - } -} - -/** - * HTTP/2 Benchmarker - */ -class H2LoadBenchmarker { - constructor() { - this.name = 'h2load'; - this.executable = 'h2load'; - const result = child_process.spawnSync(this.executable, ['-h']); - this.present = !(result.error && result.error.code === 'ENOENT'); - } - - create(options) { - const args = []; - if (typeof options.requests === 'number') - args.push('-n', options.requests); - if (typeof options.clients === 'number') - args.push('-c', options.clients); - if (typeof options.threads === 'number') - args.push('-t', options.threads); - if (typeof options.maxConcurrentStreams === 'number') - args.push('-m', options.maxConcurrentStreams); - if (typeof options.initialWindowSize === 'number') - args.push('-w', options.initialWindowSize); - if (typeof options.sessionInitialWindowSize === 'number') - args.push('-W', options.sessionInitialWindowSize); - if (typeof options.rate === 'number') - args.push('-r', options.rate); - if (typeof options.ratePeriod === 'number') - args.push(`--rate-period=${options.ratePeriod}`); - if (typeof options.duration === 'number') - args.push('-T', options.duration); - if (typeof options.timeout === 'number') - args.push('-N', options.timeout); - if (typeof options.headerTableSize === 'number') - args.push(`--header-table-size=${options.headerTableSize}`); - if (typeof options.encoderHeaderTableSize === 'number') { - args.push( - `--encoder-header-table-size=${options.encoderHeaderTableSize}`); - } - const scheme = options.scheme || 'http'; - const host = options.host || '127.0.0.1'; - args.push(`${scheme}://${host}:${options.port}${options.path}`); - const child = child_process.spawn(this.executable, args); - return child; - } - - processResults(output) { - const rex = /(\d+(?:\.\d+)) req\/s/; - return rex.exec(output)[1]; - } -} - -const http_benchmarkers = [ - new WrkBenchmarker(), - new AutocannonBenchmarker(), - new TestDoubleBenchmarker('http'), - new TestDoubleBenchmarker('http2'), - new H2LoadBenchmarker(), -]; - -const benchmarkers = {}; - -http_benchmarkers.forEach((benchmarker) => { - benchmarkers[benchmarker.name] = benchmarker; - if (!exports.default_http_benchmarker && benchmarker.present) { - exports.default_http_benchmarker = benchmarker.name; - } -}); - -exports.run = function(options, callback) { - options = Object.assign({ - port: exports.PORT, - path: '/', - connections: 100, - duration: 5, - benchmarker: exports.default_http_benchmarker, - }, options); - if (!options.benchmarker) { - callback(new Error('Could not locate required http benchmarker. See ' + - `${requirementsURL} for further instructions.`)); - return; - } - const benchmarker = benchmarkers[options.benchmarker]; - if (!benchmarker) { - callback(new Error(`Requested benchmarker '${options.benchmarker}' ` + - 'is not supported')); - return; - } - if (!benchmarker.present) { - callback(new Error(`Requested benchmarker '${options.benchmarker}' ` + - 'is not installed')); - return; - } - - const benchmarker_start = process.hrtime(); - - const child = benchmarker.create(options); - - child.stderr.pipe(process.stderr); - - let stdout = ''; - child.stdout.on('data', (chunk) => stdout += chunk.toString()); - - child.once('close', (code) => { - const elapsed = process.hrtime(benchmarker_start); - if (code) { - let error_message = `${options.benchmarker} failed with ${code}.`; - if (stdout !== '') { - error_message += ` Output: ${stdout}`; - } - callback(new Error(error_message), code); - return; - } - - const result = benchmarker.processResults(stdout); - if (result === undefined) { - callback(new Error( - `${options.benchmarker} produced strange output: ${stdout}`), code); - return; - } - - callback(null, code, options.benchmarker, result, elapsed); - }); - -}; diff --git a/deps/node/benchmark/_test-double-benchmarker.js b/deps/node/benchmark/_test-double-benchmarker.js deleted file mode 100644 index b9379b90..00000000 --- a/deps/node/benchmark/_test-double-benchmarker.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -const myModule = process.argv[2]; -if (!['http', 'http2'].includes(myModule)) { - throw new Error(`Invalid module for benchmark test double: ${myModule}`); -} - -const http = require(myModule); - -const duration = process.env.duration || 0; -const url = process.env.test_url; - -const start = process.hrtime(); -let throughput = 0; - -function request(res, client) { - res.resume(); - res.on('error', () => {}); - res.on('end', () => { - throughput++; - const diff = process.hrtime(start); - if (duration > 0 && diff[0] < duration) { - run(); - } else { - console.log(JSON.stringify({ throughput })); - if (client) { - client.destroy(); - } - } - }); -} - -function run() { - if (http.get) { // HTTP - http.get(url, request); - } else { // HTTP/2 - const client = http.connect(url); - client.on('error', (e) => { throw e; }); - request(client.request(), client); - } -} - -run(); diff --git a/deps/node/benchmark/assert/deepequal-buffer.js b/deps/node/benchmark/assert/deepequal-buffer.js deleted file mode 100644 index b8d7529e..00000000 --- a/deps/node/benchmark/assert/deepequal-buffer.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [2e4], - len: [1e2, 1e3], - strict: [0, 1], - method: [ 'deepEqual', 'notDeepEqual' ], -}); - -function main({ len, n, method, strict }) { - if (!method) - method = 'deepEqual'; - const data = Buffer.allocUnsafe(len + 1); - const actual = Buffer.alloc(len); - const expected = Buffer.alloc(len); - const expectedWrong = Buffer.alloc(len + 1); - data.copy(actual); - data.copy(expected); - data.copy(expectedWrong); - - if (strict) { - method = method.replace('eep', 'eepStrict'); - } - const fn = assert[method]; - const value2 = method.includes('not') ? expectedWrong : expected; - - bench.start(); - for (var i = 0; i < n; ++i) { - fn(actual, value2); - } - bench.end(n); -} diff --git a/deps/node/benchmark/assert/deepequal-map.js b/deps/node/benchmark/assert/deepequal-map.js deleted file mode 100644 index ea1b73ce..00000000 --- a/deps/node/benchmark/assert/deepequal-map.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = - require('assert'); - -const bench = common.createBenchmark(main, { - n: [5e2], - len: [5e2], - strict: [0, 1], - method: [ - 'deepEqual_primitiveOnly', - 'deepEqual_objectOnly', - 'deepEqual_mixed', - 'notDeepEqual_primitiveOnly', - 'notDeepEqual_objectOnly', - 'notDeepEqual_mixed', - ], -}); - -function benchmark(method, n, values, values2) { - const actual = new Map(values); - // Prevent reference equal elements - const deepCopy = JSON.parse(JSON.stringify(values2 ? values2 : values)); - const expected = new Map(deepCopy); - bench.start(); - for (var i = 0; i < n; ++i) { - method(actual, expected); - } - bench.end(n); -} - -function main({ n, len, method, strict }) { - const array = Array(len).fill(1); - var values, values2; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual_primitiveOnly': - values = array.map((_, i) => [`str_${i}`, 123]); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'deepEqual_objectOnly': - values = array.map((_, i) => [[`str_${i}`, 1], 123]); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'deepEqual_mixed': - values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'notDeepEqual_primitiveOnly': - values = array.map((_, i) => [`str_${i}`, 123]); - values2 = values.slice(0); - values2[Math.floor(len / 2)] = ['w00t', 123]; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - case 'notDeepEqual_objectOnly': - values = array.map((_, i) => [[`str_${i}`, 1], 123]); - values2 = values.slice(0); - values2[Math.floor(len / 2)] = [['w00t'], 123]; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - case 'notDeepEqual_mixed': - values = array.map((_, i) => [i % 2 ? [`str_${i}`, 1] : `str_${i}`, 123]); - values2 = values.slice(0); - values2[0] = ['w00t', 123]; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - default: - throw new Error(`Unsupported method ${method}`); - } -} diff --git a/deps/node/benchmark/assert/deepequal-object.js b/deps/node/benchmark/assert/deepequal-object.js deleted file mode 100644 index 240da23d..00000000 --- a/deps/node/benchmark/assert/deepequal-object.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [5e3], - size: [1e2, 1e3, 5e4], - strict: [0, 1], - method: [ 'deepEqual', 'notDeepEqual' ], -}); - -function createObj(source, add = '') { - return source.map((n) => ({ - foo: 'yarp', - nope: { - bar: `123${add}`, - a: [1, 2, 3], - baz: n, - c: {}, - b: [], - }, - })); -} - -function main({ size, n, method, strict }) { - // TODO: Fix this "hack". `n` should not be manipulated. - n = Math.min(Math.ceil(n / size), 20); - - if (!method) - method = 'deepEqual'; - - const source = Array.apply(null, Array(size)); - const actual = createObj(source); - const expected = createObj(source); - const expectedWrong = createObj(source, '4'); - - if (strict) { - method = method.replace('eep', 'eepStrict'); - } - const fn = assert[method]; - const value2 = method.includes('not') ? expectedWrong : expected; - - bench.start(); - for (var i = 0; i < n; ++i) { - fn(actual, value2); - } - bench.end(n); -} diff --git a/deps/node/benchmark/assert/deepequal-prims-and-objs-big-array-set.js b/deps/node/benchmark/assert/deepequal-prims-and-objs-big-array-set.js deleted file mode 100644 index 981ec3f0..00000000 --- a/deps/node/benchmark/assert/deepequal-prims-and-objs-big-array-set.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = - require('assert'); - -const primValues = { - 'string': 'a', - 'number': 1, - 'object': { 0: 'a' }, - 'array': [1, 2, 3], -}; - -const bench = common.createBenchmark(main, { - primitive: Object.keys(primValues), - n: [25], - len: [2e4], - strict: [0, 1], - method: [ - 'deepEqual_Array', - 'notDeepEqual_Array', - 'deepEqual_Set', - 'notDeepEqual_Set', - ], -}); - -function run(fn, n, actual, expected) { - bench.start(); - for (var i = 0; i < n; ++i) { - fn(actual, expected); - } - bench.end(n); -} - -function main({ n, len, primitive, method, strict }) { - const prim = primValues[primitive]; - const actual = []; - const expected = []; - const expectedWrong = []; - - for (var x = 0; x < len; x++) { - actual.push(prim); - expected.push(prim); - expectedWrong.push(prim); - } - expectedWrong.pop(); - expectedWrong.push('b'); - - // Note: primitives are only added once to a set - const actualSet = new Set(actual); - const expectedSet = new Set(expected); - const expectedWrongSet = new Set(expectedWrong); - - switch (method) { - // Empty string falls through to next line as default, mostly for tests. - case '': - case 'deepEqual_Array': - run(strict ? deepStrictEqual : deepEqual, n, actual, expected); - break; - case 'notDeepEqual_Array': - run(strict ? notDeepStrictEqual : notDeepEqual, n, actual, expectedWrong); - break; - case 'deepEqual_Set': - run(strict ? deepStrictEqual : deepEqual, n, actualSet, expectedSet); - break; - case 'notDeepEqual_Set': - run(strict ? notDeepStrictEqual : notDeepEqual, - n, actualSet, expectedWrongSet); - break; - default: - throw new Error(`Unsupported method "${method}"`); - } -} diff --git a/deps/node/benchmark/assert/deepequal-prims-and-objs-big-loop.js b/deps/node/benchmark/assert/deepequal-prims-and-objs-big-loop.js deleted file mode 100644 index 00b3c785..00000000 --- a/deps/node/benchmark/assert/deepequal-prims-and-objs-big-loop.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const primValues = { - 'string': 'a', - 'number': 1, - 'object': { 0: 'a' }, - 'array': [1, 2, 3], -}; - -const bench = common.createBenchmark(main, { - primitive: Object.keys(primValues), - n: [2e4], - strict: [0, 1], - method: [ 'deepEqual', 'notDeepEqual' ], -}); - -function main({ n, primitive, method, strict }) { - if (!method) - method = 'deepEqual'; - const prim = primValues[primitive]; - const actual = prim; - const expected = prim; - const expectedWrong = 'b'; - - if (strict) { - method = method.replace('eep', 'eepStrict'); - } - const fn = assert[method]; - const value2 = method.includes('not') ? expectedWrong : expected; - - bench.start(); - for (var i = 0; i < n; ++i) { - fn([actual], [value2]); - } - bench.end(n); -} diff --git a/deps/node/benchmark/assert/deepequal-set.js b/deps/node/benchmark/assert/deepequal-set.js deleted file mode 100644 index b4406b26..00000000 --- a/deps/node/benchmark/assert/deepequal-set.js +++ /dev/null @@ -1,78 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { deepEqual, deepStrictEqual, notDeepEqual, notDeepStrictEqual } = - require('assert'); - -const bench = common.createBenchmark(main, { - n: [5e2], - len: [5e2], - strict: [0, 1], - method: [ - 'deepEqual_primitiveOnly', - 'deepEqual_objectOnly', - 'deepEqual_mixed', - 'notDeepEqual_primitiveOnly', - 'notDeepEqual_objectOnly', - 'notDeepEqual_mixed', - ], -}); - -function benchmark(method, n, values, values2) { - const actual = new Set(values); - // Prevent reference equal elements - const deepCopy = JSON.parse(JSON.stringify(values2 ? values2 : values)); - const expected = new Set(deepCopy); - bench.start(); - for (var i = 0; i < n; ++i) { - method(actual, expected); - } - bench.end(n); -} - -function main({ n, len, method, strict }) { - const array = Array(len).fill(1); - - var values, values2; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'deepEqual_primitiveOnly': - values = array.map((_, i) => `str_${i}`); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'deepEqual_objectOnly': - values = array.map((_, i) => [`str_${i}`, null]); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'deepEqual_mixed': - values = array.map((_, i) => { - return i % 2 ? [`str_${i}`, null] : `str_${i}`; - }); - benchmark(strict ? deepStrictEqual : deepEqual, n, values); - break; - case 'notDeepEqual_primitiveOnly': - values = array.map((_, i) => `str_${i}`); - values2 = values.slice(0); - values2[Math.floor(len / 2)] = 'w00t'; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - case 'notDeepEqual_objectOnly': - values = array.map((_, i) => [`str_${i}`, null]); - values2 = values.slice(0); - values2[Math.floor(len / 2)] = ['w00t']; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - case 'notDeepEqual_mixed': - values = array.map((_, i) => { - return i % 2 ? [`str_${i}`, null] : `str_${i}`; - }); - values2 = values.slice(); - values2[0] = 'w00t'; - benchmark(strict ? notDeepStrictEqual : notDeepEqual, n, values, values2); - break; - default: - throw new Error(`Unsupported method "${method}"`); - } -} diff --git a/deps/node/benchmark/assert/deepequal-typedarrays.js b/deps/node/benchmark/assert/deepequal-typedarrays.js deleted file mode 100644 index 9acf8371..00000000 --- a/deps/node/benchmark/assert/deepequal-typedarrays.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - type: [ - 'Int8Array', - 'Uint8Array', - 'Float32Array', - 'Float64Array', - 'Uint8ClampedArray', - ], - n: [5e2], - strict: [0, 1], - method: [ - 'deepEqual', - 'notDeepEqual', - ], - len: [1e2, 5e3], -}); - -function main({ type, n, len, method, strict }) { - if (!method) - method = 'deepEqual'; - const clazz = global[type]; - const actual = new clazz(len); - const expected = new clazz(len); - const expectedWrong = new clazz(len); - const wrongIndex = Math.floor(len / 2); - expectedWrong[wrongIndex] = 123; - - if (strict) { - method = method.replace('eep', 'eepStrict'); - } - const fn = assert[method]; - const value2 = method.includes('not') ? expectedWrong : expected; - - bench.start(); - for (var i = 0; i < n; ++i) { - actual[0] = i; - value2[0] = i; - fn(actual, value2); - } - bench.end(n); -} diff --git a/deps/node/benchmark/assert/ok.js b/deps/node/benchmark/assert/ok.js deleted file mode 100644 index c50c0e06..00000000 --- a/deps/node/benchmark/assert/ok.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { n: [1e5] }); - -function main({ n }) { - var i; - bench.start(); - for (i = 0; i < n; ++i) { - if (i % 2 === 0) - assert(true); - else - assert(true, 'foo bar baz'); - } - bench.end(n); -} diff --git a/deps/node/benchmark/assert/throws.js b/deps/node/benchmark/assert/throws.js deleted file mode 100644 index 3a632637..00000000 --- a/deps/node/benchmark/assert/throws.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { throws, doesNotThrow } = require('assert'); - -const bench = common.createBenchmark(main, { - n: [1e4], - method: [ 'doesNotThrow', 'throws_TypeError', 'throws_RegExp' ], -}); - -function main({ n, method }) { - const throwError = () => { throw new TypeError('foobar'); }; - const doNotThrowError = () => { return 'foobar'; }; - const regExp = /foobar/; - const message = 'failure'; - var i; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'doesNotThrow': - bench.start(); - for (i = 0; i < n; ++i) { - doesNotThrow(doNotThrowError); - } - bench.end(n); - break; - case 'throws_TypeError': - bench.start(); - for (i = 0; i < n; ++i) { - throws(throwError, TypeError, message); - } - bench.end(n); - break; - case 'throws_RegExp': - bench.start(); - for (i = 0; i < n; ++i) { - throws(throwError, regExp, message); - } - bench.end(n); - break; - default: - throw new Error(`Unsupported method ${method}`); - } -} diff --git a/deps/node/benchmark/async_hooks/gc-tracking.js b/deps/node/benchmark/async_hooks/gc-tracking.js deleted file mode 100644 index d74b2bac..00000000 --- a/deps/node/benchmark/async_hooks/gc-tracking.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { AsyncResource } = require('async_hooks'); - -const bench = common.createBenchmark(main, { - n: [1e6], - method: [ - 'trackingEnabled', - 'trackingDisabled', - ] -}, { - flags: ['--expose-gc'] -}); - -function endAfterGC(n) { - setImmediate(() => { - global.gc(); - setImmediate(() => { - bench.end(n); - }); - }); -} - -function main({ n, method }) { - var i; - switch (method) { - case 'trackingEnabled': - bench.start(); - for (i = 0; i < n; i++) { - new AsyncResource('foobar'); - } - endAfterGC(n); - break; - case 'trackingDisabled': - bench.start(); - for (i = 0; i < n; i++) { - new AsyncResource('foobar', { requireManualDestroy: true }); - } - endAfterGC(n); - break; - default: - throw new Error(`Unsupported method "${method}"`); - } -} diff --git a/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js b/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js deleted file mode 100644 index 7aee5a89..00000000 --- a/deps/node/benchmark/buffers/buffer-base64-decode-wrapped.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - charsPerLine: [76], - linesCount: [8 << 16], - n: [32], -}); - -function main({ charsPerLine, linesCount, n }) { - const bytesCount = charsPerLine * linesCount / 4 * 3; - - const line = `${'abcd'.repeat(charsPerLine / 4)}\n`; - const data = line.repeat(linesCount); - // eslint-disable-next-line node-core/no-unescaped-regexp-dot - data.match(/./); // Flatten the string - const buffer = Buffer.alloc(bytesCount, line, 'base64'); - - bench.start(); - for (var i = 0; i < n; i++) { - buffer.base64Write(data, 0, bytesCount); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-base64-decode.js b/deps/node/benchmark/buffers/buffer-base64-decode.js deleted file mode 100644 index 0ac694fe..00000000 --- a/deps/node/benchmark/buffers/buffer-base64-decode.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -const assert = require('assert'); -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [32], - size: [8 << 20] -}); - -function main({ n, size }) { - const s = 'abcd'.repeat(size); - // eslint-disable-next-line node-core/no-unescaped-regexp-dot - s.match(/./); // Flatten string. - assert.strictEqual(s.length % 4, 0); - const b = Buffer.allocUnsafe(s.length / 4 * 3); - b.write(s, 0, s.length, 'base64'); - bench.start(); - for (var i = 0; i < n; i += 1) b.base64Write(s, 0, s.length); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-base64-encode.js b/deps/node/benchmark/buffers/buffer-base64-encode.js deleted file mode 100644 index d8b601bb..00000000 --- a/deps/node/benchmark/buffers/buffer-base64-encode.js +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - len: [64 * 1024 * 1024], - n: [32] -}); - -function main({ n, len }) { - const b = Buffer.allocUnsafe(len); - let s = ''; - let i; - for (i = 0; i < 256; ++i) s += String.fromCharCode(i); - for (i = 0; i < len; i += 256) b.write(s, i, 256, 'ascii'); - bench.start(); - for (i = 0; i < n; ++i) b.toString('base64'); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-bytelength.js b/deps/node/benchmark/buffers/buffer-bytelength.js deleted file mode 100644 index 4caad301..00000000 --- a/deps/node/benchmark/buffers/buffer-bytelength.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; -const common = require('../common'); - -const bench = common.createBenchmark(main, { - encoding: ['utf8', 'base64', 'buffer'], - len: [1, 2, 4, 16, 64, 256], // x16 - n: [5e6] -}); - -// 16 chars each -const chars = [ - 'hello brendan!!!', // 1 byte - 'ΰαβγδεζηθικλμνξο', // 2 bytes - '挰挱挲挳挴挵挶挷挸挹挺挻挼挽挾挿', // 3 bytes - '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢', // 4 bytes -]; - -function main({ n, len, encoding }) { - var strings = []; - var results = [ len * 16 ]; - if (encoding === 'buffer') { - strings = [ Buffer.alloc(len * 16, 'a') ]; - } else { - for (const string of chars) { - // Strings must be built differently, depending on encoding - const data = string.repeat(len); - if (encoding === 'utf8') { - strings.push(data); - } else if (encoding === 'base64') { - // Base64 strings will be much longer than their UTF8 counterparts - strings.push(Buffer.from(data, 'utf8').toString('base64')); - } - } - - // Check the result to ensure it is *properly* optimized - results = strings.map((val) => Buffer.byteLength(val, encoding)); - } - - bench.start(); - for (var i = 0; i < n; i++) { - const index = n % strings.length; - // Go! - const r = Buffer.byteLength(strings[index], encoding); - - if (r !== results[index]) - throw new Error('incorrect return value'); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-compare-instance-method.js b/deps/node/benchmark/buffers/buffer-compare-instance-method.js deleted file mode 100644 index 77a3e84f..00000000 --- a/deps/node/benchmark/buffers/buffer-compare-instance-method.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - size: [16, 512, 1024, 4096, 16386], - args: [1, 2, 3, 4, 5], - n: [1e6] -}); - -function main({ n, size, args }) { - const b0 = Buffer.alloc(size, 'a'); - const b1 = Buffer.alloc(size, 'a'); - const b0Len = b0.length; - const b1Len = b1.length; - var i; - - b1[size - 1] = 'b'.charCodeAt(0); - - switch (args) { - case 2: - b0.compare(b1, 0); - break; - case 3: - b0.compare(b1, 0, b1Len); - break; - case 4: - b0.compare(b1, 0, b1Len, 0); - break; - case 5: - b0.compare(b1, 0, b1Len, 0, b0Len); - break; - default: - b0.compare(b1); - } - switch (args) { - case 2: - b0.compare(b1, 0); - bench.start(); - for (i = 0; i < n; i++) { - b0.compare(b1, 0); - } - bench.end(n); - break; - case 3: - b0.compare(b1, 0, b1Len); - bench.start(); - for (i = 0; i < n; i++) { - b0.compare(b1, 0, b1Len); - } - bench.end(n); - break; - case 4: - b0.compare(b1, 0, b1Len, 0); - bench.start(); - for (i = 0; i < n; i++) { - b0.compare(b1, 0, b1Len, 0); - } - bench.end(n); - break; - case 5: - b0.compare(b1, 0, b1Len, 0, b0Len); - bench.start(); - for (i = 0; i < n; i++) { - b0.compare(b1, 0, b1Len, 0, b0Len); - } - bench.end(n); - break; - default: - b0.compare(b1); - bench.start(); - for (i = 0; i < n; i++) { - b0.compare(b1); - } - bench.end(n); - } -} diff --git a/deps/node/benchmark/buffers/buffer-compare-offset.js b/deps/node/benchmark/buffers/buffer-compare-offset.js deleted file mode 100644 index 89cc4427..00000000 --- a/deps/node/benchmark/buffers/buffer-compare-offset.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - method: ['offset', 'slice'], - size: [16, 512, 1024, 4096, 16386], - n: [1e6] -}); - -function compareUsingSlice(b0, b1, len, iter) { - for (var i = 0; i < iter; i++) - Buffer.compare(b0.slice(1, len), b1.slice(1, len)); -} - -function compareUsingOffset(b0, b1, len, iter) { - for (var i = 0; i < iter; i++) - b0.compare(b1, 1, len, 1, len); -} - -function main({ n, size, method }) { - const fn = method === 'slice' ? compareUsingSlice : compareUsingOffset; - bench.start(); - fn(Buffer.alloc(size, 'a'), - Buffer.alloc(size, 'b'), - size >> 1, - n); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-compare.js b/deps/node/benchmark/buffers/buffer-compare.js deleted file mode 100644 index cb4f0f47..00000000 --- a/deps/node/benchmark/buffers/buffer-compare.js +++ /dev/null @@ -1,41 +0,0 @@ -// Copyright Joyent, Inc. and other Node contributors. -// -// Permission is hereby granted, free of charge, to any person obtaining a -// copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to permit -// persons to whom the Software is furnished to do so, subject to the -// following conditions: -// -// The above copyright notice and this permission notice shall be included -// in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN -// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, -// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -// USE OR OTHER DEALINGS IN THE SOFTWARE. - -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - size: [16, 512, 1024, 4096, 16386], - n: [1e6] -}); - -function main({ n, size }) { - const b0 = Buffer.alloc(size, 'a'); - const b1 = Buffer.alloc(size, 'a'); - - b1[size - 1] = 'b'.charCodeAt(0); - - bench.start(); - for (var i = 0; i < n; i++) { - Buffer.compare(b0, b1); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-concat.js b/deps/node/benchmark/buffers/buffer-concat.js deleted file mode 100644 index 3f9cffc0..00000000 --- a/deps/node/benchmark/buffers/buffer-concat.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - pieces: [1, 4, 16], - pieceSize: [1, 16, 256], - withTotalLength: [0, 1], - n: [1024] -}); - -function main({ n, pieces, pieceSize, withTotalLength }) { - const list = new Array(pieces); - list.fill(Buffer.allocUnsafe(pieceSize)); - - const totalLength = withTotalLength ? pieces * pieceSize : undefined; - - bench.start(); - for (var i = 0; i < n * 1024; i++) { - Buffer.concat(list, totalLength); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-creation.js b/deps/node/benchmark/buffers/buffer-creation.js deleted file mode 100644 index a7b34013..00000000 --- a/deps/node/benchmark/buffers/buffer-creation.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; -const SlowBuffer = require('buffer').SlowBuffer; - -const common = require('../common.js'); -const assert = require('assert'); -const bench = common.createBenchmark(main, { - type: [ - 'fast-alloc', - 'fast-alloc-fill', - 'fast-allocUnsafe', - 'slow-allocUnsafe', - 'slow', - 'buffer()'], - len: [10, 1024, 2048, 4096, 8192], - n: [1024] -}); - -function main({ len, n, type }) { - let fn, i; - switch (type) { - case '': - case 'fast-alloc': - fn = Buffer.alloc; - break; - case 'fast-alloc-fill': - bench.start(); - for (i = 0; i < n * 1024; i++) { - Buffer.alloc(len, 0); - } - bench.end(n); - return; - case 'fast-allocUnsafe': - fn = Buffer.allocUnsafe; - break; - case 'slow-allocUnsafe': - fn = Buffer.allocUnsafeSlow; - break; - case 'slow': - fn = SlowBuffer; - break; - case 'buffer()': - fn = Buffer; - break; - default: - assert.fail('Should not get here'); - } - - bench.start(); - for (i = 0; i < n * 1024; i++) { - fn(len); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-fill.js b/deps/node/benchmark/buffers/buffer-fill.js deleted file mode 100644 index b497597f..00000000 --- a/deps/node/benchmark/buffers/buffer-fill.js +++ /dev/null @@ -1,31 +0,0 @@ -'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); -} diff --git a/deps/node/benchmark/buffers/buffer-from.js b/deps/node/benchmark/buffers/buffer-from.js deleted file mode 100644 index 437bf930..00000000 --- a/deps/node/benchmark/buffers/buffer-from.js +++ /dev/null @@ -1,98 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); -const bench = common.createBenchmark(main, { - source: [ - 'array', - 'arraybuffer', - 'arraybuffer-middle', - 'buffer', - 'uint8array', - 'string', - 'string-utf8', - 'string-base64', - 'object', - ], - len: [10, 2048], - n: [2048] -}); - -function main({ len, n, source }) { - const array = new Array(len).fill(42); - const arrayBuf = new ArrayBuffer(len); - const str = 'a'.repeat(len); - const buffer = Buffer.allocUnsafe(len); - const uint8array = new Uint8Array(len); - const obj = { length: null }; // Results in a new, empty Buffer - - switch (source) { - case 'array': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(array); - } - bench.end(n); - break; - case 'arraybuffer': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(arrayBuf); - } - bench.end(n); - break; - case 'arraybuffer-middle': - const offset = ~~(len / 4); - const length = ~~(len / 2); - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(arrayBuf, offset, length); - } - bench.end(n); - break; - case 'buffer': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(buffer); - } - bench.end(n); - break; - case 'uint8array': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(uint8array); - } - bench.end(n); - break; - case 'string': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(str); - } - bench.end(n); - break; - case 'string-utf8': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(str, 'utf8'); - } - bench.end(n); - break; - case 'string-base64': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(str, 'base64'); - } - bench.end(n); - break; - case 'object': - bench.start(); - for (let i = 0; i < n * 1024; i++) { - Buffer.from(obj); - } - bench.end(n); - break; - default: - assert.fail('Should not get here'); - } -} diff --git a/deps/node/benchmark/buffers/buffer-hex.js b/deps/node/benchmark/buffers/buffer-hex.js deleted file mode 100644 index 4d873139..00000000 --- a/deps/node/benchmark/buffers/buffer-hex.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - len: [0, 1, 64, 1024], - n: [1e7] -}); - -function main({ len, n }) { - const buf = Buffer.alloc(len); - var i; - - for (i = 0; i < buf.length; i++) - buf[i] = i & 0xff; - - const hex = buf.toString('hex'); - - bench.start(); - - for (i = 0; i < n; i += 1) - Buffer.from(hex, 'hex'); - - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-indexof-number.js b/deps/node/benchmark/buffers/buffer-indexof-number.js deleted file mode 100644 index 91bff0d5..00000000 --- a/deps/node/benchmark/buffers/buffer-indexof-number.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const fs = require('fs'); -const path = require('path'); - -const bench = common.createBenchmark(main, { - value: ['@'.charCodeAt(0)], - n: [1e7] -}); - -function main({ n, value }) { - const aliceBuffer = fs.readFileSync( - path.resolve(__dirname, '../fixtures/alice.html') - ); - - bench.start(); - for (var i = 0; i < n; i++) { - aliceBuffer.indexOf(value, 0, undefined); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-indexof.js b/deps/node/benchmark/buffers/buffer-indexof.js deleted file mode 100644 index f3b9dcf1..00000000 --- a/deps/node/benchmark/buffers/buffer-indexof.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const fs = require('fs'); -const path = require('path'); - -const searchStrings = [ - '@', - 'SQ', - '10x', - '--l', - 'Alice', - 'Gryphon', - 'Panther', - 'Ou est ma chatte?', - 'found it very', - 'among mad people', - 'neighbouring pool', - 'Soo--oop', - 'aaaaaaaaaaaaaaaaa', - 'venture to go near the house till she had brought herself down to', - '</i> to the Caterpillar', -]; - -const bench = common.createBenchmark(main, { - search: searchStrings, - encoding: ['undefined', 'utf8', 'ucs2', 'binary'], - type: ['buffer', 'string'], - n: [100000] -}); - -function main({ n, search, encoding, type }) { - var aliceBuffer = fs.readFileSync( - path.resolve(__dirname, '../fixtures/alice.html') - ); - - if (encoding === 'undefined') { - encoding = undefined; - } - - if (encoding === 'ucs2') { - aliceBuffer = Buffer.from(aliceBuffer.toString(), encoding); - } - - if (type === 'buffer') { - search = Buffer.from(Buffer.from(search).toString(), encoding); - } - - bench.start(); - for (var i = 0; i < n; i++) { - aliceBuffer.indexOf(search, 0, encoding); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-iterate.js b/deps/node/benchmark/buffers/buffer-iterate.js deleted file mode 100644 index 7a275b0b..00000000 --- a/deps/node/benchmark/buffers/buffer-iterate.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; -const SlowBuffer = require('buffer').SlowBuffer; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - size: [16, 512, 1024, 4096, 16386], - type: ['fast', 'slow'], - method: ['for', 'forOf', 'iterator'], - n: [1e3] -}); - -const methods = { - 'for': benchFor, - 'forOf': benchForOf, - 'iterator': benchIterator -}; - -function main({ size, type, method, n }) { - const clazz = type === 'fast' ? Buffer : SlowBuffer; - const buffer = new clazz(size); - buffer.fill(0); - const fn = methods[method || 'for']; - - bench.start(); - fn(buffer, n); - bench.end(n); -} - -function benchFor(buffer, n) { - for (var k = 0; k < n; k++) { - for (var i = 0; i < buffer.length; i++) { - assert(buffer[i] === 0); - } - } -} - -function benchForOf(buffer, n) { - for (var k = 0; k < n; k++) { - for (const b of buffer) { - assert(b === 0); - } - } -} - -function benchIterator(buffer, n) { - for (var k = 0; k < n; k++) { - const iter = buffer[Symbol.iterator](); - var cur = iter.next(); - - while (!cur.done) { - assert(cur.value === 0); - cur = iter.next(); - } - - } -} diff --git a/deps/node/benchmark/buffers/buffer-normalize-encoding.js b/deps/node/benchmark/buffers/buffer-normalize-encoding.js deleted file mode 100644 index e33f7e0b..00000000 --- a/deps/node/benchmark/buffers/buffer-normalize-encoding.js +++ /dev/null @@ -1,43 +0,0 @@ -'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); -} diff --git a/deps/node/benchmark/buffers/buffer-read-float.js b/deps/node/benchmark/buffers/buffer-read-float.js deleted file mode 100644 index dbccf573..00000000 --- a/deps/node/benchmark/buffers/buffer-read-float.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - type: ['Double', 'Float'], - endian: ['BE', 'LE'], - value: ['zero', 'big', 'small', 'inf', 'nan'], - n: [1e6] -}); - -function main({ n, type, endian, value }) { - type = type || 'Double'; - const buff = Buffer.alloc(8); - const fn = `read${type}${endian}`; - const values = { - Double: { - zero: 0, - big: 2 ** 1023, - small: 2 ** -1074, - inf: Infinity, - nan: NaN, - }, - Float: { - zero: 0, - big: 2 ** 127, - small: 2 ** -149, - inf: Infinity, - nan: NaN, - }, - }; - - buff[`write${type}${endian}`](values[type][value], 0); - - bench.start(); - for (var i = 0; i !== n; i++) { - buff[fn](0); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-read-with-byteLength.js b/deps/node/benchmark/buffers/buffer-read-with-byteLength.js deleted file mode 100644 index 65d5f8f0..00000000 --- a/deps/node/benchmark/buffers/buffer-read-with-byteLength.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const types = [ - 'IntBE', - 'IntLE', - 'UIntBE', - 'UIntLE', -]; - -const bench = common.createBenchmark(main, { - buffer: ['fast', 'slow'], - type: types, - n: [1e6], - byteLength: [1, 2, 3, 4, 5, 6] -}); - -function main({ n, buf, type, byteLength }) { - const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; - const buff = new clazz(8); - const fn = `read${type || 'IntBE'}`; - - buff.writeDoubleLE(0, 0); - bench.start(); - for (var i = 0; i !== n; i++) { - buff[fn](0, byteLength); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-read.js b/deps/node/benchmark/buffers/buffer-read.js deleted file mode 100644 index 38a9a847..00000000 --- a/deps/node/benchmark/buffers/buffer-read.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const types = [ - 'UInt8', - 'UInt16LE', - 'UInt16BE', - 'UInt32LE', - 'UInt32BE', - 'Int8', - 'Int16LE', - 'Int16BE', - 'Int32LE', - 'Int32BE', - 'FloatLE', - 'FloatBE', - 'DoubleLE', - 'DoubleBE', -]; - -const bench = common.createBenchmark(main, { - buffer: ['fast', 'slow'], - type: types, - n: [1e6] -}); - -function main({ n, buf, type }) { - const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; - const buff = new clazz(8); - const fn = `read${type || 'UInt8'}`; - - buff.writeDoubleLE(0, 0); - bench.start(); - - for (var i = 0; i !== n; i++) { - buff[fn](0); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-slice.js b/deps/node/benchmark/buffers/buffer-slice.js deleted file mode 100644 index 2e52475d..00000000 --- a/deps/node/benchmark/buffers/buffer-slice.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const SlowBuffer = require('buffer').SlowBuffer; - -const bench = common.createBenchmark(main, { - type: ['fast', 'slow'], - n: [1024] -}); - -const buf = Buffer.allocUnsafe(1024); -const slowBuf = new SlowBuffer(1024); - -function main({ n, type }) { - const b = type === 'fast' ? buf : slowBuf; - bench.start(); - for (var i = 0; i < n * 1024; i++) { - b.slice(10, 256); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-swap.js b/deps/node/benchmark/buffers/buffer-swap.js deleted file mode 100644 index a85bcf32..00000000 --- a/deps/node/benchmark/buffers/buffer-swap.js +++ /dev/null @@ -1,83 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - aligned: ['true', 'false'], - method: ['swap16', 'swap32', 'swap64'/* , 'htons', 'htonl', 'htonll' */], - len: [8, 64, 128, 256, 512, 768, 1024, 1536, 2056, 4096, 8192], - n: [5e7] -}); - -// The htons and htonl methods below are used to benchmark the -// performance difference between doing the byteswap in pure -// javascript regardless of Buffer size as opposed to dropping -// down to the native layer for larger Buffer sizes. Commented -// out by default because they are slow for big buffers. If -// re-evaluating the crossover point, uncomment those methods -// and comment out their implementations in lib/buffer.js so -// C++ version will always be used. - -function swap(b, n, m) { - const i = b[n]; - b[n] = b[m]; - b[m] = i; -} - -Buffer.prototype.htons = function htons() { - if (this.length % 2 !== 0) - throw new RangeError(); - for (var i = 0; i < this.length; i += 2) { - swap(this, i, i + 1); - } - return this; -}; - -Buffer.prototype.htonl = function htonl() { - if (this.length % 4 !== 0) - throw new RangeError(); - for (var i = 0; i < this.length; i += 4) { - swap(this, i, i + 3); - swap(this, i + 1, i + 2); - } - return this; -}; - -Buffer.prototype.htonll = function htonll() { - if (this.length % 8 !== 0) - throw new RangeError(); - for (var i = 0; i < this.length; i += 8) { - swap(this, i, i + 7); - swap(this, i + 1, i + 6); - swap(this, i + 2, i + 5); - swap(this, i + 3, i + 4); - } - return this; -}; - -function createBuffer(len, aligned) { - len += aligned ? 0 : 1; - const buf = Buffer.allocUnsafe(len); - for (var i = 1; i <= len; i++) - buf[i - 1] = i; - return aligned ? buf : buf.slice(1); -} - -function genMethod(method) { - const fnString = ` - return function ${method}(n, buf) { - for (var i = 0; i <= n; i++) - buf.${method}(); - }`; - return (new Function(fnString))(); -} - -function main({ method, len, n, aligned = 'true' }) { - const buf = createBuffer(len, aligned === 'true'); - const bufferSwap = genMethod(method || 'swap16'); - - bufferSwap(n, buf); - bench.start(); - bufferSwap(n, buf); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-tojson.js b/deps/node/benchmark/buffers/buffer-tojson.js deleted file mode 100644 index 71936fb6..00000000 --- a/deps/node/benchmark/buffers/buffer-tojson.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1e4], - len: [0, 10, 256, 4 * 1024] -}); - -function main({ n, len }) { - const buf = Buffer.allocUnsafe(len); - - bench.start(); - for (var i = 0; i < n; ++i) - buf.toJSON(); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-tostring.js b/deps/node/benchmark/buffers/buffer-tostring.js deleted file mode 100644 index b2a14d8a..00000000 --- a/deps/node/benchmark/buffers/buffer-tostring.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - encoding: ['', 'utf8', 'ascii', 'latin1', 'binary', 'hex', 'UCS-2'], - args: [0, 1, 2, 3], - len: [0, 1, 64, 1024], - n: [1e7] -}); - -function main({ encoding, args, len, n }) { - const buf = Buffer.alloc(len, 42); - - if (encoding.length === 0) - encoding = undefined; - - var i; - switch (args) { - case 1: - bench.start(); - for (i = 0; i < n; i += 1) - buf.toString(encoding); - bench.end(n); - break; - case 2: - bench.start(); - for (i = 0; i < n; i += 1) - buf.toString(encoding, 0); - bench.end(n); - break; - case 3: - bench.start(); - for (i = 0; i < n; i += 1) - buf.toString(encoding, 0, len); - bench.end(n); - break; - default: - bench.start(); - for (i = 0; i < n; i += 1) - buf.toString(); - bench.end(n); - break; - } -} diff --git a/deps/node/benchmark/buffers/buffer-write-string.js b/deps/node/benchmark/buffers/buffer-write-string.js deleted file mode 100644 index 6bd98ba4..00000000 --- a/deps/node/benchmark/buffers/buffer-write-string.js +++ /dev/null @@ -1,65 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - encoding: [ - '', 'utf8', 'ascii', 'hex', 'UCS-2', 'utf16le', 'latin1', 'binary', - ], - args: [ '', 'offset', 'offset+length' ], - len: [10, 2048], - n: [1e7] -}); - -function main({ len, n, encoding, args }) { - const string = 'a'.repeat(len); - const buf = Buffer.allocUnsafe(len); - - var i; - - switch (args) { - case 'offset': - if (encoding) { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string, 0, encoding); - } - bench.end(n); - } else { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string, 0); - } - bench.end(n); - } - break; - case 'offset+length': - if (encoding) { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string, 0, buf.length, encoding); - } - bench.end(n); - } else { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string, 0, buf.length); - } - bench.end(n); - } - break; - default: - if (encoding) { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string, encoding); - } - bench.end(n); - } else { - bench.start(); - for (i = 0; i < n; ++i) { - buf.write(string); - } - bench.end(n); - } - } -} diff --git a/deps/node/benchmark/buffers/buffer-write.js b/deps/node/benchmark/buffers/buffer-write.js deleted file mode 100644 index 33d33a63..00000000 --- a/deps/node/benchmark/buffers/buffer-write.js +++ /dev/null @@ -1,101 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const types = [ - 'UInt8', - 'UInt16LE', - 'UInt16BE', - 'UInt32LE', - 'UInt32BE', - 'UIntLE', - 'UIntBE', - 'Int8', - 'Int16LE', - 'Int16BE', - 'Int32LE', - 'Int32BE', - 'IntLE', - 'IntBE', - 'FloatLE', - 'FloatBE', - 'DoubleLE', - 'DoubleBE', -]; - -const bench = common.createBenchmark(main, { - buffer: ['fast', 'slow'], - type: types, - n: [1e6] -}); - -const INT8 = 0x7f; -const INT16 = 0x7fff; -const INT32 = 0x7fffffff; -const INT48 = 0x7fffffffffff; -const UINT8 = 0xff; -const UINT16 = 0xffff; -const UINT32 = 0xffffffff; - -const mod = { - writeInt8: INT8, - writeInt16BE: INT16, - writeInt16LE: INT16, - writeInt32BE: INT32, - writeInt32LE: INT32, - writeUInt8: UINT8, - writeUInt16BE: UINT16, - writeUInt16LE: UINT16, - writeUInt32BE: UINT32, - writeUInt32LE: UINT32, - writeUIntLE: INT8, - writeUIntBE: INT16, - writeIntLE: INT32, - writeIntBE: INT48 -}; - -const byteLength = { - writeUIntLE: 1, - writeUIntBE: 2, - writeIntLE: 4, - writeIntBE: 6 -}; - -function main({ n, buf, type }) { - const clazz = buf === 'fast' ? Buffer : require('buffer').SlowBuffer; - const buff = new clazz(8); - const fn = `write${type || 'UInt8'}`; - - if (!/\d/.test(fn)) - benchSpecialInt(buff, fn, n); - else if (/Int/.test(fn)) - benchInt(buff, fn, n); - else - benchFloat(buff, fn, n); -} - -function benchInt(buff, fn, n) { - const m = mod[fn]; - bench.start(); - for (var i = 0; i !== n; i++) { - buff[fn](i & m, 0); - } - bench.end(n); -} - -function benchSpecialInt(buff, fn, n) { - const m = mod[fn]; - const byte = byteLength[fn]; - bench.start(); - for (var i = 0; i !== n; i++) { - buff[fn](i & m, 0, byte); - } - bench.end(n); -} - -function benchFloat(buff, fn, n) { - bench.start(); - for (var i = 0; i !== n; i++) { - buff[fn](i, 0); - } - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/buffer-zero.js b/deps/node/benchmark/buffers/buffer-zero.js deleted file mode 100644 index 1263732d..00000000 --- a/deps/node/benchmark/buffers/buffer-zero.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1024], - type: ['buffer', 'string'] -}); - -const zeroBuffer = Buffer.alloc(0); -const zeroString = ''; - -function main({ n, type }) { - const data = type === 'buffer' ? zeroBuffer : zeroString; - - bench.start(); - for (var i = 0; i < n * 1024; i++) Buffer.from(data); - bench.end(n); -} diff --git a/deps/node/benchmark/buffers/dataview-set.js b/deps/node/benchmark/buffers/dataview-set.js deleted file mode 100644 index a22cad93..00000000 --- a/deps/node/benchmark/buffers/dataview-set.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const types = [ - 'Uint8', - 'Uint16LE', - 'Uint16BE', - 'Uint32LE', - 'Uint32BE', - 'Int8', - 'Int16LE', - 'Int16BE', - 'Int32LE', - 'Int32BE', - 'Float32LE', - 'Float32BE', - 'Float64LE', - 'Float64BE', -]; - -const bench = common.createBenchmark(main, { - type: types, - n: [1e6] -}); - -const INT8 = 0x7f; -const INT16 = 0x7fff; -const INT32 = 0x7fffffff; -const UINT8 = INT8 * 2; -const UINT16 = INT16 * 2; -const UINT32 = INT32 * 2; - -const mod = { - setInt8: INT8, - setInt16: INT16, - setInt32: INT32, - setUint8: UINT8, - setUint16: UINT16, - setUint32: UINT32 -}; - -function main({ n, type }) { - type = type || 'Uint8'; - const ab = new ArrayBuffer(8); - const dv = new DataView(ab, 0, 8); - const le = /LE$/.test(type); - const fn = `set${type.replace(/[LB]E$/, '')}`; - - if (/int/i.test(fn)) - benchInt(dv, fn, n, le); - else - benchFloat(dv, fn, n, le); -} - -function benchInt(dv, fn, len, le) { - const m = mod[fn]; - const method = dv[fn]; - bench.start(); - for (var i = 0; i < len; i++) { - method.call(dv, 0, i % m, le); - } - bench.end(len); -} - -function benchFloat(dv, fn, len, le) { - const method = dv[fn]; - bench.start(); - for (var i = 0; i < len; i++) { - method.call(dv, 0, i * 0.1, le); - } - bench.end(len); -} diff --git a/deps/node/benchmark/child_process/child-process-exec-stdout.js b/deps/node/benchmark/child_process/child-process-exec-stdout.js deleted file mode 100644 index a1dc4aa0..00000000 --- a/deps/node/benchmark/child_process/child-process-exec-stdout.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { exec, execSync } = require('child_process'); -const isWindows = process.platform === 'win32'; - -const messagesLength = [64, 256, 1024, 4096]; -// Windows does not support command lines longer than 8191 characters -if (!isWindows) messagesLength.push(32768); - -const bench = common.createBenchmark(childProcessExecStdout, { - len: messagesLength, - dur: [5] -}); - -function childProcessExecStdout({ dur, len }) { - bench.start(); - - const maxDuration = dur * 1000; - const cmd = `yes "${'.'.repeat(len)}"`; - const child = exec(cmd, { 'stdio': ['ignore', 'pipe', 'ignore'] }); - - var bytes = 0; - child.stdout.on('data', (msg) => { - bytes += msg.length; - }); - - setTimeout(() => { - bench.end(bytes); - if (isWindows) { - // Sometimes there's a yes.exe process left hanging around on Windows. - try { - execSync(`taskkill /f /t /pid ${child.pid}`); - } catch { - // This is a best effort kill. stderr is piped to parent for tracing. - } - } else { - child.kill(); - } - }, maxDuration); -} diff --git a/deps/node/benchmark/child_process/child-process-params.js b/deps/node/benchmark/child_process/child-process-params.js deleted file mode 100644 index df930395..00000000 --- a/deps/node/benchmark/child_process/child-process-params.js +++ /dev/null @@ -1,142 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const cp = require('child_process'); - -const command = 'echo'; -const args = ['hello']; -const options = {}; -const cb = () => {}; - -const configs = { - n: [1e3], - methodName: [ - 'exec', 'execSync', - 'execFile', 'execFileSync', - 'spawn', 'spawnSync', - ], - params: [1, 2, 3, 4], -}; - -const bench = common.createBenchmark(main, configs); - -function main({ n, methodName, params }) { - const method = cp[methodName]; - - switch (methodName) { - case 'exec': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command).kill(); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, options).kill(); - bench.end(n); - break; - case 3: - bench.start(); - for (let i = 0; i < n; i++) method(command, options, cb).kill(); - bench.end(n); - break; - } - break; - case 'execSync': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, options); - bench.end(n); - break; - } - break; - case 'execFile': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command).kill(); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, args).kill(); - bench.end(n); - break; - case 3: - bench.start(); - for (let i = 0; i < n; i++) method(command, args, options).kill(); - bench.end(n); - break; - case 4: - bench.start(); - for (let i = 0; i < n; i++) method(command, args, options, cb).kill(); - bench.end(n); - break; - } - break; - case 'execFileSync': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, args); - bench.end(n); - break; - case 3: - bench.start(); - for (let i = 0; i < n; i++) method(command, args, options); - bench.end(n); - break; - } - break; - case 'spawn': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command).kill(); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, args).kill(); - bench.end(n); - break; - case 3: - bench.start(); - for (let i = 0; i < n; i++) method(command, args, options).kill(); - bench.end(n); - break; - } - break; - case 'spawnSync': - switch (params) { - case 1: - bench.start(); - for (let i = 0; i < n; i++) method(command); - bench.end(n); - break; - case 2: - bench.start(); - for (let i = 0; i < n; i++) method(command, args); - bench.end(n); - break; - case 3: - bench.start(); - for (let i = 0; i < n; i++) method(command, args, options); - bench.end(n); - break; - } - break; - } -} diff --git a/deps/node/benchmark/child_process/child-process-read-ipc.js b/deps/node/benchmark/child_process/child-process-read-ipc.js deleted file mode 100644 index a9e9cdf7..00000000 --- a/deps/node/benchmark/child_process/child-process-read-ipc.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; -if (process.argv[2] === 'child') { - const len = +process.argv[3]; - const msg = '.'.repeat(len); - const send = () => { - while (process.send(msg)); - // Wait: backlog of unsent messages exceeds threshold - setImmediate(send); - }; - send(); -} else { - const common = require('../common.js'); - const bench = common.createBenchmark(main, { - len: [ - 64, 256, 1024, 4096, 16384, 65536, - 65536 << 4, 65536 << 8, - ], - dur: [5] - }); - const spawn = require('child_process').spawn; - - function main({ dur, len }) { - bench.start(); - - const options = { 'stdio': ['ignore', 1, 2, 'ipc'] }; - const child = spawn(process.argv[0], - [process.argv[1], 'child', len], options); - - var bytes = 0; - child.on('message', (msg) => { bytes += msg.length; }); - - setTimeout(() => { - child.kill(); - bench.end(bytes); - }, dur * 1000); - } -} diff --git a/deps/node/benchmark/child_process/child-process-read.js b/deps/node/benchmark/child_process/child-process-read.js deleted file mode 100644 index 3c014411..00000000 --- a/deps/node/benchmark/child_process/child-process-read.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -// This benchmark uses `yes` to a create noisy child_processes with varying -// output message lengths, and tries to read 8GB of output - -const os = require('os'); -const child_process = require('child_process'); - -const messagesLength = [64, 256, 1024, 4096]; -// Windows does not support that long arguments -if (os.platform() !== 'win32') - messagesLength.push(32768); - -const bench = common.createBenchmark(main, { - len: messagesLength, - dur: [5] -}); - -function main({ dur, len }) { - bench.start(); - - const msg = `"${'.'.repeat(len)}"`; - const options = { 'stdio': ['ignore', 'pipe', 'ignore'] }; - const child = child_process.spawn('yes', [msg], options); - - var bytes = 0; - child.stdout.on('data', (msg) => { - bytes += msg.length; - }); - - setTimeout(() => { - if (process.platform === 'win32') { - // Sometimes there's a yes.exe process left hanging around on Windows... - child_process.execSync(`taskkill /f /t /pid ${child.pid}`); - } else { - child.kill(); - } - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); - }, dur * 1000); -} diff --git a/deps/node/benchmark/child_process/spawn-echo.js b/deps/node/benchmark/child_process/spawn-echo.js deleted file mode 100644 index 8f5c80cd..00000000 --- a/deps/node/benchmark/child_process/spawn-echo.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [1000] -}); - -const spawn = require('child_process').spawn; -function main({ n }) { - bench.start(); - go(n, n); -} - -function go(n, left) { - if (--left === 0) - return bench.end(n); - - const child = spawn('echo', ['hello']); - child.on('exit', (code) => { - if (code) - process.exit(code); - else - go(n, left); - }); -} diff --git a/deps/node/benchmark/cluster/echo.js b/deps/node/benchmark/cluster/echo.js deleted file mode 100644 index 73c5971c..00000000 --- a/deps/node/benchmark/cluster/echo.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; - -const cluster = require('cluster'); -if (cluster.isMaster) { - const common = require('../common.js'); - const bench = common.createBenchmark(main, { - workers: [1], - payload: ['string', 'object'], - sendsPerBroadcast: [1, 10], - n: [1e5] - }); - - function main({ n, workers, sendsPerBroadcast, payload }) { - const expectedPerBroadcast = sendsPerBroadcast * workers; - var readies = 0; - var broadcasts = 0; - var msgCount = 0; - var data; - - switch (payload) { - case 'string': - data = 'hello world!'; - break; - case 'object': - data = { action: 'pewpewpew', powerLevel: 9001 }; - break; - default: - throw new Error('Unsupported payload type'); - } - - for (var i = 0; i < workers; ++i) - cluster.fork().on('online', onOnline).on('message', onMessage); - - function onOnline() { - if (++readies === workers) { - bench.start(); - broadcast(); - } - } - - function broadcast() { - var id; - if (broadcasts++ === n) { - bench.end(n); - for (id in cluster.workers) - cluster.workers[id].disconnect(); - return; - } - for (id in cluster.workers) { - const worker = cluster.workers[id]; - for (var i = 0; i < sendsPerBroadcast; ++i) - worker.send(data); - } - } - - function onMessage() { - if (++msgCount === expectedPerBroadcast) { - msgCount = 0; - broadcast(); - } - } - } -} else { - process.on('message', (msg) => { - process.send(msg); - }); -} diff --git a/deps/node/benchmark/common.js b/deps/node/benchmark/common.js deleted file mode 100644 index cad05509..00000000 --- a/deps/node/benchmark/common.js +++ /dev/null @@ -1,348 +0,0 @@ -'use strict'; - -const child_process = require('child_process'); -const http_benchmarkers = require('./_http-benchmarkers.js'); - -exports.buildType = process.features.debug ? 'Debug' : 'Release'; - -exports.createBenchmark = function(fn, configs, options) { - return new Benchmark(fn, configs, options); -}; - -function Benchmark(fn, configs, options) { - // Use the file name as the name of the benchmark - this.name = require.main.filename.slice(__dirname.length + 1); - // Parse job-specific configuration from the command line arguments - const parsed_args = this._parseArgs(process.argv.slice(2), configs); - this.options = parsed_args.cli; - this.extra_options = parsed_args.extra; - // The configuration list as a queue of jobs - this.queue = this._queue(this.options); - // The configuration of the current job, head of the queue - this.config = this.queue[0]; - // Execution arguments i.e. flags used to run the jobs - this.flags = []; - if (options && options.flags) { - this.flags = this.flags.concat(options.flags); - } - // Holds process.hrtime value - this._time = [0, 0]; - // Used to make sure a benchmark only start a timer once - this._started = false; - - // this._run will use fork() to create a new process for each configuration - // combination. - if (process.env.hasOwnProperty('NODE_RUN_BENCHMARK_FN')) { - process.nextTick(() => fn(this.config)); - } else { - process.nextTick(() => this._run()); - } -} - -Benchmark.prototype._parseArgs = function(argv, configs) { - const cliOptions = {}; - const extraOptions = {}; - const validArgRE = /^(.+?)=([\s\S]*)$/; - // Parse configuration arguments - for (const arg of argv) { - const match = arg.match(validArgRE); - if (!match) { - console.error(`bad argument: ${arg}`); - process.exit(1); - } - const config = match[1]; - - if (configs[config]) { - // Infer the type from the config object and parse accordingly - const isNumber = typeof configs[config][0] === 'number'; - const value = isNumber ? +match[2] : match[2]; - if (!cliOptions[config]) - cliOptions[config] = []; - cliOptions[config].push(value); - } else { - extraOptions[config] = match[2]; - } - } - return { cli: Object.assign({}, configs, cliOptions), extra: extraOptions }; -}; - -Benchmark.prototype._queue = function(options) { - const queue = []; - const keys = Object.keys(options); - - // Perform a depth-first walk though all options to generate a - // configuration list that contains all combinations. - function recursive(keyIndex, prevConfig) { - const key = keys[keyIndex]; - const values = options[key]; - const type = typeof values[0]; - - for (const value of values) { - if (typeof value !== 'number' && typeof value !== 'string') { - throw new TypeError(`configuration "${key}" had type ${typeof value}`); - } - if (typeof value !== type) { - // This is a requirement for being able to consistently and predictably - // parse CLI provided configuration values. - throw new TypeError(`configuration "${key}" has mixed types`); - } - - const currConfig = Object.assign({ [key]: value }, prevConfig); - - if (keyIndex + 1 < keys.length) { - recursive(keyIndex + 1, currConfig); - } else { - queue.push(currConfig); - } - } - } - - if (keys.length > 0) { - recursive(0, {}); - } else { - queue.push({}); - } - - return queue; -}; - -// Benchmark an http server. -exports.default_http_benchmarker = - http_benchmarkers.default_http_benchmarker; -exports.PORT = http_benchmarkers.PORT; - -Benchmark.prototype.http = function(options, cb) { - const self = this; - const http_options = Object.assign({ }, options); - http_options.benchmarker = http_options.benchmarker || - self.config.benchmarker || - self.extra_options.benchmarker || - exports.default_http_benchmarker; - http_benchmarkers.run( - http_options, (error, code, used_benchmarker, result, elapsed) => { - if (cb) { - cb(code); - } - if (error) { - console.error(error); - process.exit(code || 1); - } - self.config.benchmarker = used_benchmarker; - self.report(result, elapsed); - } - ); -}; - -Benchmark.prototype._run = function() { - const self = this; - // If forked, report to the parent. - if (process.send) { - process.send({ - type: 'config', - name: this.name, - queueLength: this.queue.length, - }); - } - - (function recursive(queueIndex) { - const config = self.queue[queueIndex]; - - // Set NODE_RUN_BENCHMARK_FN to indicate that the child shouldn't construct - // a configuration queue, but just execute the benchmark function. - const childEnv = Object.assign({}, process.env); - childEnv.NODE_RUN_BENCHMARK_FN = ''; - - // Create configuration arguments - const childArgs = []; - for (const key of Object.keys(config)) { - childArgs.push(`${key}=${config[key]}`); - } - for (const key of Object.keys(self.extra_options)) { - childArgs.push(`${key}=${self.extra_options[key]}`); - } - - const child = child_process.fork(require.main.filename, childArgs, { - env: childEnv, - execArgv: self.flags.concat(process.execArgv), - }); - child.on('message', sendResult); - child.on('close', (code) => { - if (code) { - process.exit(code); - } - - if (queueIndex + 1 < self.queue.length) { - recursive(queueIndex + 1); - } - }); - })(0); -}; - -Benchmark.prototype.start = function() { - if (this._started) { - throw new Error('Called start more than once in a single benchmark'); - } - this._started = true; - this._time = process.hrtime(); -}; - -Benchmark.prototype.end = function(operations) { - // Get elapsed time now and do error checking later for accuracy. - const elapsed = process.hrtime(this._time); - - if (!this._started) { - throw new Error('called end without start'); - } - if (typeof operations !== 'number') { - throw new Error('called end() without specifying operation count'); - } - if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED && operations <= 0) { - throw new Error('called end() with operation count <= 0'); - } - if (elapsed[0] === 0 && elapsed[1] === 0) { - if (!process.env.NODEJS_BENCHMARK_ZERO_ALLOWED) - throw new Error('insufficient clock precision for short benchmark'); - // avoid dividing by zero - elapsed[1] = 1; - } - - const time = elapsed[0] + elapsed[1] / 1e9; - const rate = operations / time; - this.report(rate, elapsed); -}; - -function formatResult(data) { - // Construct configuration string, " A=a, B=b, ..." - let conf = ''; - for (const key of Object.keys(data.conf)) { - conf += ` ${key}=${JSON.stringify(data.conf[key])}`; - } - - var rate = data.rate.toString().split('.'); - rate[0] = rate[0].replace(/(\d)(?=(?:\d\d\d)+(?!\d))/g, '$1,'); - rate = (rate[1] ? rate.join('.') : rate[0]); - return `${data.name}${conf}: ${rate}`; -} - -function sendResult(data) { - if (process.send) { - // If forked, report by process send - process.send(data); - } else { - // Otherwise report by stdout - console.log(formatResult(data)); - } -} -exports.sendResult = sendResult; - -Benchmark.prototype.report = function(rate, elapsed) { - sendResult({ - name: this.name, - conf: this.config, - rate: rate, - time: elapsed[0] + elapsed[1] / 1e9, - type: 'report', - }); -}; - -exports.binding = function(bindingName) { - try { - const { internalBinding } = require('internal/test/binding'); - - return internalBinding(bindingName); - } catch { - return process.binding(bindingName); - } -}; - -const urls = { - long: 'http://nodejs.org:89/docs/latest/api/foo/bar/qua/13949281/0f28b/' + - '/5d49/b3020/url.html#test?payload1=true&payload2=false&test=1' + - '&benchmark=3&foo=38.38.011.293&bar=1234834910480&test=19299&3992&' + - 'key=f5c65e1e98fe07e648249ad41e1cfdb0', - short: 'https://nodejs.org/en/blog/', - idn: 'http://你好你好.在线', - auth: 'https://user:pass@example.com/path?search=1', - file: 'file:///foo/bar/test/node.js', - ws: 'ws://localhost:9229/f46db715-70df-43ad-a359-7f9949f39868', - javascript: 'javascript:alert("node is awesome");', - percent: 'https://%E4%BD%A0/foo', - dot: 'https://example.org/./a/../b/./c', -}; -exports.urls = urls; - -const searchParams = { - noencode: 'foo=bar&baz=quux&xyzzy=thud', - multicharsep: 'foo=bar&&&&&&&&&&baz=quux&&&&&&&&&&xyzzy=thud', - encodefake: 'foo=%©ar&baz=%A©uux&xyzzy=%©ud', - encodemany: '%66%6F%6F=bar&%62%61%7A=quux&xyzzy=%74h%75d', - encodelast: 'foo=bar&baz=quux&xyzzy=thu%64', - multivalue: 'foo=bar&foo=baz&foo=quux&quuy=quuz', - multivaluemany: 'foo=bar&foo=baz&foo=quux&quuy=quuz&foo=abc&foo=def&' + - 'foo=ghi&foo=jkl&foo=mno&foo=pqr&foo=stu&foo=vwxyz', - manypairs: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z', - manyblankpairs: '&&&&&&&&&&&&&&&&&&&&&&&&', - altspaces: 'foo+bar=baz+quux&xyzzy+thud=quuy+quuz&abc=def+ghi', -}; -exports.searchParams = searchParams; - -function getUrlData(withBase) { - const data = require('../test/fixtures/wpt/url/resources/urltestdata.json'); - const result = []; - for (const item of data) { - if (item.failure || !item.input) continue; - if (withBase) { - result.push([item.input, item.base]); - } else if (item.base !== 'about:blank') { - result.push(item.base); - } - } - return result; -} - -exports.urlDataTypes = Object.keys(urls).concat(['wpt']); - -/** - * Generate an array of data for URL benchmarks to use. - * The size of the resulting data set is the original data size * 2 ** `e`. - * The 'wpt' type contains about 400 data points when `withBase` is true, - * and 200 data points when `withBase` is false. - * Other types contain 200 data points with or without base. - * - * @param {string} type Type of the data, 'wpt' or a key of `urls` - * @param {number} e The repetition of the data, as exponent of 2 - * @param {boolean} withBase Whether to include a base URL - * @param {boolean} asUrl Whether to return the results as URL objects - * @return {string[] | string[][] | URL[]} - */ -function bakeUrlData(type, e = 0, withBase = false, asUrl = false) { - let result = []; - if (type === 'wpt') { - result = getUrlData(withBase); - } else if (urls[type]) { - const input = urls[type]; - const item = withBase ? [input, 'about:blank'] : input; - // Roughly the size of WPT URL test data - result = new Array(200).fill(item); - } else { - throw new Error(`Unknown url data type ${type}`); - } - - if (typeof e !== 'number') { - throw new Error(`e must be a number, received ${e}`); - } - - for (let i = 0; i < e; ++i) { - result = result.concat(result); - } - - if (asUrl) { - if (withBase) { - result = result.map(([input, base]) => new URL(input, base)); - } else { - result = result.map((input) => new URL(input)); - } - } - return result; -} -exports.bakeUrlData = bakeUrlData; diff --git a/deps/node/benchmark/compare.R b/deps/node/benchmark/compare.R deleted file mode 100644 index 7a0c89af..00000000 --- a/deps/node/benchmark/compare.R +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/env Rscript -library(ggplot2); -library(plyr); - -# get __dirname and load ./_cli.R -args = commandArgs(trailingOnly = F); -dirname = dirname(sub("--file=", "", args[grep("--file", args)])); -source(paste0(dirname, '/_cli.R'), chdir=T); - -if (!is.null(args.options$help) || - (!is.null(args.options$plot) && args.options$plot == TRUE)) { - stop("usage: cat file.csv | Rscript compare.R - --help show this message - --plot filename save plot to filename"); -} - -plot.filename = args.options$plot; - -dat = read.csv( - file('stdin'), - colClasses=c('character', 'character', 'character', 'numeric', 'numeric') -); -dat = data.frame(dat); - -dat$nameTwoLines = paste0(dat$filename, '\n', dat$configuration); -dat$name = paste0(dat$filename, dat$configuration); - -# Create a box plot -if (!is.null(plot.filename)) { - p = ggplot(data=dat); - p = p + geom_boxplot(aes(x=nameTwoLines, y=rate, fill=binary)); - p = p + ylab("rate of operations (higher is better)"); - p = p + xlab("benchmark"); - p = p + theme(axis.text.x = element_text(angle = 90, hjust = 1, vjust = 0.5)); - ggsave(plot.filename, p); -} - -# computes the shared standard error, as used in the welch t-test -welch.sd = function (old.rate, new.rate) { - old.se.squared = var(old.rate) / length(old.rate) - new.se.squared = var(new.rate) / length(new.rate) - return(sqrt(old.se.squared + new.se.squared)) -} - -# calculate the improvement confidence interval. The improvement is calculated -# by dividing by old.mu and not new.mu, because old.mu is what the mean -# improvement is calculated relative to. -confidence.interval = function (shared.se, old.mu, w, risk) { - interval = qt(1 - (risk / 2), w$parameter) * shared.se; - return(sprintf("±%.2f%%", (interval / old.mu) * 100)) -} - -# Print a table with results -statistics = ddply(dat, "name", function(subdat) { - old.rate = subset(subdat, binary == "old")$rate; - new.rate = subset(subdat, binary == "new")$rate; - - # Calculate improvement for the "new" binary compared with the "old" binary - old.mu = mean(old.rate); - new.mu = mean(new.rate); - improvement = sprintf("%.2f %%", ((new.mu - old.mu) / old.mu * 100)); - - r = list( - confidence = "NA", - improvement = improvement, - "accuracy (*)" = "NA", - "(**)" = "NA", - "(***)" = "NA" - ); - - # Check if there is enough data to calculate the calculate the p-value - if (length(old.rate) > 1 && length(new.rate) > 1) { - # Perform a statistics test to see of there actually is a difference in - # performance. - w = t.test(rate ~ binary, data=subdat); - shared.se = welch.sd(old.rate, new.rate) - - # Add user friendly stars to the table. There should be at least one star - # before you can say that there is an improvement. - confidence = ''; - if (w$p.value < 0.001) { - confidence = '***'; - } else if (w$p.value < 0.01) { - confidence = '**'; - } else if (w$p.value < 0.05) { - confidence = '*'; - } - - r = list( - confidence = confidence, - improvement = improvement, - "accuracy (*)" = confidence.interval(shared.se, old.mu, w, 0.05), - "(**)" = confidence.interval(shared.se, old.mu, w, 0.01), - "(***)" = confidence.interval(shared.se, old.mu, w, 0.001) - ); - } - - return(data.frame(r, check.names=FALSE)); -}); - - -# Set the benchmark names as the row.names to left align them in the print -row.names(statistics) = statistics$name; -statistics$name = NULL; - -options(width = 200); -print(statistics); -cat("\n") -cat(sprintf( -"Be aware that when doing many comparisons the risk of a false-positive -result increases. In this case there are %d comparisons, you can thus -expect the following amount of false-positive results: - %.2f false positives, when considering a 5%% risk acceptance (*, **, ***), - %.2f false positives, when considering a 1%% risk acceptance (**, ***), - %.2f false positives, when considering a 0.1%% risk acceptance (***) -", -nrow(statistics), -nrow(statistics) * 0.05, -nrow(statistics) * 0.01, -nrow(statistics) * 0.001)) diff --git a/deps/node/benchmark/compare.js b/deps/node/benchmark/compare.js deleted file mode 100644 index bd7c4a95..00000000 --- a/deps/node/benchmark/compare.js +++ /dev/null @@ -1,110 +0,0 @@ -'use strict'; - -const { fork } = require('child_process'); -const { inspect } = require('util'); -const path = require('path'); -const CLI = require('./_cli.js'); -const BenchmarkProgress = require('./_benchmark_progress.js'); - -// -// Parse arguments -// -const cli = CLI(`usage: ./node compare.js [options] [--] <category> ... - Run each benchmark in the <category> directory many times using two different - node versions. More than one <category> directory can be specified. - The output is formatted as csv, which can be processed using for - example 'compare.R'. - - --new ./new-node-binary new node binary (required) - --old ./old-node-binary old node binary (required) - --runs 30 number of samples - --filter pattern string to filter benchmark scripts - --set variable=value set benchmark variable (can be repeated) - --no-progress don't show benchmark progress indicator -`, { arrayArgs: ['set'], boolArgs: ['no-progress'] }); - -if (!cli.optional.new || !cli.optional.old) { - cli.abort(cli.usage); -} - -const binaries = ['old', 'new']; -const runs = cli.optional.runs ? parseInt(cli.optional.runs, 10) : 30; -const benchmarks = cli.benchmarks(); - -if (benchmarks.length === 0) { - console.error('No benchmarks found'); - process.exitCode = 1; - return; -} - -// Create queue from the benchmarks list such both node versions are tested -// `runs` amount of times each. -// Note: BenchmarkProgress relies on this order to estimate -// how much runs remaining for a file. All benchmarks generated from -// the same file must be run consecutively. -const queue = []; -for (const filename of benchmarks) { - for (let iter = 0; iter < runs; iter++) { - for (const binary of binaries) { - queue.push({ binary, filename, iter }); - } - } -} -// queue.length = binary.length * runs * benchmarks.length - -// Print csv header -console.log('"binary", "filename", "configuration", "rate", "time"'); - -const kStartOfQueue = 0; - -const showProgress = !cli.optional['no-progress']; -let progress; -if (showProgress) { - progress = new BenchmarkProgress(queue, benchmarks); - progress.startQueue(kStartOfQueue); -} - -(function recursive(i) { - const job = queue[i]; - - const child = fork(path.resolve(__dirname, job.filename), cli.optional.set, { - execPath: cli.optional[job.binary] - }); - - child.on('message', (data) => { - if (data.type === 'report') { - // Construct configuration string, " A=a, B=b, ..." - let conf = ''; - for (const key of Object.keys(data.conf)) { - conf += ` ${key}=${inspect(data.conf[key])}`; - } - conf = conf.slice(1); - // Escape quotes (") for correct csv formatting - conf = conf.replace(/"/g, '""'); - - console.log(`"${job.binary}", "${job.filename}", "${conf}", ` + - `${data.rate}, ${data.time}`); - if (showProgress) { - // One item in the subqueue has been completed. - progress.completeConfig(data); - } - } else if (showProgress && data.type === 'config') { - // The child has computed the configurations, ready to run subqueue. - progress.startSubqueue(data, i); - } - }); - - child.once('close', (code) => { - if (code) { - process.exit(code); - } - if (showProgress) { - progress.completeRun(job); - } - - // If there are more benchmarks execute the next - if (i + 1 < queue.length) { - recursive(i + 1); - } - }); -})(kStartOfQueue); diff --git a/deps/node/benchmark/crypto/aes-gcm-throughput.js b/deps/node/benchmark/crypto/aes-gcm-throughput.js deleted file mode 100644 index cd8f29c8..00000000 --- a/deps/node/benchmark/crypto/aes-gcm-throughput.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const crypto = require('crypto'); -const keylen = { 'aes-128-gcm': 16, 'aes-192-gcm': 24, 'aes-256-gcm': 32 }; -const bench = common.createBenchmark(main, { - n: [500], - cipher: ['aes-128-gcm', 'aes-192-gcm', 'aes-256-gcm'], - len: [1024, 4 * 1024, 16 * 1024, 64 * 1024, 256 * 1024, 1024 * 1024] -}); - -function main({ n, len, cipher }) { - // Default cipher for tests. - if (cipher === '') - cipher = 'aes-128-gcm'; - const message = Buffer.alloc(len, 'b'); - const key = crypto.randomBytes(keylen[cipher]); - const iv = crypto.randomBytes(12); - const associate_data = Buffer.alloc(16, 'z'); - bench.start(); - AEAD_Bench(cipher, message, associate_data, key, iv, n, len); -} - -function AEAD_Bench(cipher, message, associate_data, key, iv, n, len) { - const written = n * len; - const bits = written * 8; - const mbits = bits / (1024 * 1024); - - for (var i = 0; i < n; i++) { - const alice = crypto.createCipheriv(cipher, key, iv); - alice.setAAD(associate_data); - const enc = alice.update(message); - alice.final(); - const tag = alice.getAuthTag(); - const bob = crypto.createDecipheriv(cipher, key, iv); - bob.setAuthTag(tag); - bob.setAAD(associate_data); - bob.update(enc); - bob.final(); - } - - bench.end(mbits); -} diff --git a/deps/node/benchmark/crypto/cipher-stream.js b/deps/node/benchmark/crypto/cipher-stream.js deleted file mode 100644 index f426a327..00000000 --- a/deps/node/benchmark/crypto/cipher-stream.js +++ /dev/null @@ -1,103 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - writes: [500], - cipher: [ 'AES192', 'AES256' ], - type: ['asc', 'utf', 'buf'], - len: [2, 1024, 102400, 1024 * 1024], - api: ['legacy', 'stream'] -}); - -function main({ api, cipher, type, len, writes }) { - // Default cipher for tests. - if (cipher === '') - cipher = 'AES192'; - if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { - console.error('Crypto streams not available until v0.10'); - // Use the legacy, just so that we can compare them. - api = 'legacy'; - } - - const crypto = require('crypto'); - const assert = require('assert'); - const alice = crypto.getDiffieHellman('modp5'); - const bob = crypto.getDiffieHellman('modp5'); - - alice.generateKeys(); - bob.generateKeys(); - - - const pubEnc = /^v0\.[0-8]/.test(process.version) ? 'binary' : null; - const alice_secret = alice.computeSecret(bob.getPublicKey(), pubEnc, 'hex'); - const bob_secret = bob.computeSecret(alice.getPublicKey(), pubEnc, 'hex'); - - // alice_secret and bob_secret should be the same - assert(alice_secret === bob_secret); - - const alice_cipher = crypto.createCipher(cipher, alice_secret); - const bob_cipher = crypto.createDecipher(cipher, bob_secret); - - var message; - var encoding; - switch (type) { - case 'asc': - message = 'a'.repeat(len); - encoding = 'ascii'; - break; - case 'utf': - message = 'ü'.repeat(len / 2); - encoding = 'utf8'; - break; - case 'buf': - message = Buffer.alloc(len, 'b'); - break; - default: - throw new Error(`unknown message type: ${type}`); - } - - const fn = api === 'stream' ? streamWrite : legacyWrite; - - // Write data as fast as possible to alice, and have bob decrypt. - // use old API for comparison to v0.8 - bench.start(); - fn(alice_cipher, bob_cipher, message, encoding, writes); -} - -function streamWrite(alice, bob, message, encoding, writes) { - var written = 0; - bob.on('data', (c) => { - written += c.length; - }); - - bob.on('end', () => { - // Gbits - const bits = written * 8; - const gbits = bits / (1024 * 1024 * 1024); - bench.end(gbits); - }); - - alice.pipe(bob); - - while (writes-- > 0) - alice.write(message, encoding); - - alice.end(); -} - -function legacyWrite(alice, bob, message, encoding, writes) { - var written = 0; - var enc, dec; - for (var i = 0; i < writes; i++) { - enc = alice.update(message, encoding); - dec = bob.update(enc); - written += dec.length; - } - enc = alice.final(); - dec = bob.update(enc); - written += dec.length; - dec = bob.final(); - written += dec.length; - const gbits = written / (1024 * 1024 * 1024); - bench.end(gbits); -} diff --git a/deps/node/benchmark/crypto/get-ciphers.js b/deps/node/benchmark/crypto/get-ciphers.js deleted file mode 100644 index 5bbe0915..00000000 --- a/deps/node/benchmark/crypto/get-ciphers.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1, 5000], - v: ['crypto', 'tls'] -}); - -function main({ n, v }) { - const method = require(v).getCiphers; - var i = 0; - // First call to getCiphers will dominate the results - if (n > 1) { - for (; i < n; i++) - method(); - } - bench.start(); - for (i = 0; i < n; i++) method(); - bench.end(n); -} diff --git a/deps/node/benchmark/crypto/hash-stream-creation.js b/deps/node/benchmark/crypto/hash-stream-creation.js deleted file mode 100644 index 8ffbe148..00000000 --- a/deps/node/benchmark/crypto/hash-stream-creation.js +++ /dev/null @@ -1,82 +0,0 @@ -// throughput benchmark -// creates a single hasher, then pushes a bunch of data through it -'use strict'; -const common = require('../common.js'); -const crypto = require('crypto'); - -const bench = common.createBenchmark(main, { - writes: [500], - algo: [ 'sha256', 'md5' ], - type: ['asc', 'utf', 'buf'], - out: ['hex', 'binary', 'buffer'], - len: [2, 1024, 102400, 1024 * 1024], - api: ['legacy', 'stream'] -}); - -function main({ api, type, len, out, writes, algo }) { - if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { - console.error('Crypto streams not available until v0.10'); - // Use the legacy, just so that we can compare them. - api = 'legacy'; - } - - var message; - var encoding; - switch (type) { - case 'asc': - message = 'a'.repeat(len); - encoding = 'ascii'; - break; - case 'utf': - message = 'ü'.repeat(len / 2); - encoding = 'utf8'; - break; - case 'buf': - message = Buffer.alloc(len, 'b'); - break; - default: - throw new Error(`unknown message type: ${type}`); - } - - const fn = api === 'stream' ? streamWrite : legacyWrite; - - bench.start(); - fn(algo, message, encoding, writes, len, out); -} - -function legacyWrite(algo, message, encoding, writes, len, outEnc) { - const written = writes * len; - const bits = written * 8; - const gbits = bits / (1024 * 1024 * 1024); - - while (writes-- > 0) { - const h = crypto.createHash(algo); - h.update(message, encoding); - var res = h.digest(outEnc); - - // Include buffer creation costs for older versions - if (outEnc === 'buffer' && typeof res === 'string') - res = Buffer.from(res, 'binary'); - } - - bench.end(gbits); -} - -function streamWrite(algo, message, encoding, writes, len, outEnc) { - const written = writes * len; - const bits = written * 8; - const gbits = bits / (1024 * 1024 * 1024); - - while (writes-- > 0) { - const h = crypto.createHash(algo); - - if (outEnc !== 'buffer') - h.setEncoding(outEnc); - - h.write(message, encoding); - h.end(); - h.read(); - } - - bench.end(gbits); -} diff --git a/deps/node/benchmark/crypto/hash-stream-throughput.js b/deps/node/benchmark/crypto/hash-stream-throughput.js deleted file mode 100644 index 6ce7a676..00000000 --- a/deps/node/benchmark/crypto/hash-stream-throughput.js +++ /dev/null @@ -1,73 +0,0 @@ -// throughput benchmark -// creates a single hasher, then pushes a bunch of data through it -'use strict'; -const common = require('../common.js'); -const crypto = require('crypto'); - -const bench = common.createBenchmark(main, { - writes: [500], - algo: ['sha1', 'sha256', 'sha512'], - type: ['asc', 'utf', 'buf'], - len: [2, 1024, 102400, 1024 * 1024], - api: ['legacy', 'stream'] -}); - -function main({ api, type, len, algo, writes }) { - if (api === 'stream' && /^v0\.[0-8]\./.test(process.version)) { - console.error('Crypto streams not available until v0.10'); - // Use the legacy, just so that we can compare them. - api = 'legacy'; - } - - var message; - var encoding; - switch (type) { - case 'asc': - message = 'a'.repeat(len); - encoding = 'ascii'; - break; - case 'utf': - message = 'ü'.repeat(len / 2); - encoding = 'utf8'; - break; - case 'buf': - message = Buffer.alloc(len, 'b'); - break; - default: - throw new Error(`unknown message type: ${type}`); - } - - const fn = api === 'stream' ? streamWrite : legacyWrite; - - bench.start(); - fn(algo, message, encoding, writes, len); -} - -function legacyWrite(algo, message, encoding, writes, len) { - const written = writes * len; - const bits = written * 8; - const gbits = bits / (1024 * 1024 * 1024); - const h = crypto.createHash(algo); - - while (writes-- > 0) - h.update(message, encoding); - - h.digest(); - - bench.end(gbits); -} - -function streamWrite(algo, message, encoding, writes, len) { - const written = writes * len; - const bits = written * 8; - const gbits = bits / (1024 * 1024 * 1024); - const h = crypto.createHash(algo); - - while (writes-- > 0) - h.write(message, encoding); - - h.end(); - h.read(); - - bench.end(gbits); -} diff --git a/deps/node/benchmark/crypto/rsa-encrypt-decrypt-throughput.js b/deps/node/benchmark/crypto/rsa-encrypt-decrypt-throughput.js deleted file mode 100644 index 13153c20..00000000 --- a/deps/node/benchmark/crypto/rsa-encrypt-decrypt-throughput.js +++ /dev/null @@ -1,44 +0,0 @@ -'use strict'; -// Throughput benchmark in signing and verifying -const common = require('../common.js'); -const crypto = require('crypto'); -const fs = require('fs'); -const path = require('path'); -const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/'); -const keylen_list = ['1024', '2048', '4096']; -const RSA_PublicPem = {}; -const RSA_PrivatePem = {}; - -keylen_list.forEach((key) => { - RSA_PublicPem[key] = - fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`); - RSA_PrivatePem[key] = - fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`); -}); - -const bench = common.createBenchmark(main, { - n: [500], - keylen: keylen_list, - len: [16, 32, 64] -}); - -function main({ len, algo, keylen, n }) { - const message = Buffer.alloc(len, 'b'); - bench.start(); - StreamWrite(algo, keylen, message, n, len); -} - -function StreamWrite(algo, keylen, message, n, len) { - const written = n * len; - const bits = written * 8; - const kbits = bits / (1024); - - const privateKey = RSA_PrivatePem[keylen]; - const publicKey = RSA_PublicPem[keylen]; - for (var i = 0; i < n; i++) { - const enc = crypto.privateEncrypt(privateKey, message); - crypto.publicDecrypt(publicKey, enc); - } - - bench.end(kbits); -} diff --git a/deps/node/benchmark/crypto/rsa-sign-verify-throughput.js b/deps/node/benchmark/crypto/rsa-sign-verify-throughput.js deleted file mode 100644 index 846fa1b9..00000000 --- a/deps/node/benchmark/crypto/rsa-sign-verify-throughput.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; -// Throughput benchmark in signing and verifying -const common = require('../common.js'); -const crypto = require('crypto'); -const fs = require('fs'); -const path = require('path'); -const fixtures_keydir = path.resolve(__dirname, '../../test/fixtures/keys/'); -const keylen_list = ['1024', '2048']; -const RSA_PublicPem = {}; -const RSA_PrivatePem = {}; - -keylen_list.forEach((key) => { - RSA_PublicPem[key] = - fs.readFileSync(`${fixtures_keydir}/rsa_public_${key}.pem`); - RSA_PrivatePem[key] = - fs.readFileSync(`${fixtures_keydir}/rsa_private_${key}.pem`); -}); - -const bench = common.createBenchmark(main, { - writes: [500], - algo: ['SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512'], - keylen: keylen_list, - len: [1024, 102400, 2 * 102400, 3 * 102400, 1024 * 1024] -}); - -function main({ len, algo, keylen, writes }) { - const message = Buffer.alloc(len, 'b'); - bench.start(); - StreamWrite(algo, keylen, message, writes, len); -} - -function StreamWrite(algo, keylen, message, writes, len) { - const written = writes * len; - const bits = written * 8; - const kbits = bits / (1024); - - const privateKey = RSA_PrivatePem[keylen]; - const s = crypto.createSign(algo); - const v = crypto.createVerify(algo); - - while (writes-- > 0) { - s.update(message); - v.update(message); - } - - s.sign(privateKey, 'binary'); - s.end(); - v.end(); - - bench.end(kbits); -} diff --git a/deps/node/benchmark/dgram/array-vs-concat.js b/deps/node/benchmark/dgram/array-vs-concat.js deleted file mode 100644 index 669cf47d..00000000 --- a/deps/node/benchmark/dgram/array-vs-concat.js +++ /dev/null @@ -1,59 +0,0 @@ -// Test UDP send throughput with the multi buffer API against Buffer.concat -'use strict'; - -const common = require('../common.js'); -const dgram = require('dgram'); -const PORT = common.PORT; - -// `num` is the number of send requests to queue up each time. -// Keep it reasonably high (>10) otherwise you're benchmarking the speed of -// event loop cycles more than anything else. -const bench = common.createBenchmark(main, { - len: [64, 256, 512, 1024], - num: [100], - chunks: [1, 2, 4, 8], - type: ['concat', 'multi'], - dur: [5] -}); - -function main({ dur, len, num, type, chunks }) { - const chunk = []; - for (var i = 0; i < chunks; i++) { - chunk.push(Buffer.allocUnsafe(Math.round(len / chunks))); - } - - // Server - var sent = 0; - const socket = dgram.createSocket('udp4'); - const onsend = type === 'concat' ? onsendConcat : onsendMulti; - - function onsendConcat() { - if (sent++ % num === 0) { - for (var i = 0; i < num; i++) { - socket.send(Buffer.concat(chunk), PORT, '127.0.0.1', onsend); - } - } - } - - function onsendMulti() { - if (sent++ % num === 0) { - for (var i = 0; i < num; i++) { - socket.send(chunk, PORT, '127.0.0.1', onsend); - } - } - } - - socket.on('listening', () => { - bench.start(); - onsend(); - - setTimeout(() => { - const bytes = sent * len; - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); - process.exit(0); - }, dur * 1000); - }); - - socket.bind(PORT); -} diff --git a/deps/node/benchmark/dgram/bind-params.js b/deps/node/benchmark/dgram/bind-params.js deleted file mode 100644 index ea1f430e..00000000 --- a/deps/node/benchmark/dgram/bind-params.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const dgram = require('dgram'); - -const configs = { - n: [1e4], - port: ['true', 'false'], - address: ['true', 'false'], -}; - -const bench = common.createBenchmark(main, configs); -const noop = () => {}; - -function main({ n, port, address }) { - port = port === 'true' ? 0 : undefined; - address = address === 'true' ? '0.0.0.0' : undefined; - var i; - - if (port !== undefined && address !== undefined) { - bench.start(); - for (i = 0; i < n; i++) { - dgram.createSocket('udp4').bind(port, address) - .on('error', noop) - .unref(); - } - bench.end(n); - } else if (port !== undefined) { - bench.start(); - for (i = 0; i < n; i++) { - dgram.createSocket('udp4') - .bind(port) - .on('error', noop) - .unref(); - } - bench.end(n); - } else if (port === undefined && address === undefined) { - bench.start(); - for (i = 0; i < n; i++) { - dgram.createSocket('udp4') - .bind() - .on('error', noop) - .unref(); - } - bench.end(n); - } -} diff --git a/deps/node/benchmark/dgram/multi-buffer.js b/deps/node/benchmark/dgram/multi-buffer.js deleted file mode 100644 index a1c50551..00000000 --- a/deps/node/benchmark/dgram/multi-buffer.js +++ /dev/null @@ -1,53 +0,0 @@ -// test UDP send/recv throughput with the multi buffer API -'use strict'; - -const common = require('../common.js'); -const dgram = require('dgram'); -const PORT = common.PORT; - -// `num` is the number of send requests to queue up each time. -// Keep it reasonably high (>10) otherwise you're benchmarking the speed of -// event loop cycles more than anything else. -const bench = common.createBenchmark(main, { - len: [64, 256, 1024], - num: [100], - chunks: [1, 2, 4, 8], - type: ['send', 'recv'], - dur: [5] -}); - -function main({ dur, len, num, type, chunks }) { - const chunk = []; - for (var i = 0; i < chunks; i++) { - chunk.push(Buffer.allocUnsafe(Math.round(len / chunks))); - } - var sent = 0; - var received = 0; - const socket = dgram.createSocket('udp4'); - - function onsend() { - if (sent++ % num === 0) { - for (var i = 0; i < num; i++) { - socket.send(chunk, PORT, '127.0.0.1', onsend); - } - } - } - - socket.on('listening', () => { - bench.start(); - onsend(); - - setTimeout(() => { - const bytes = (type === 'send' ? sent : received) * len; - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); - process.exit(0); - }, dur * 1000); - }); - - socket.on('message', () => { - received++; - }); - - socket.bind(PORT); -} diff --git a/deps/node/benchmark/dgram/offset-length.js b/deps/node/benchmark/dgram/offset-length.js deleted file mode 100644 index 7c672aca..00000000 --- a/deps/node/benchmark/dgram/offset-length.js +++ /dev/null @@ -1,49 +0,0 @@ -// Test UDP send/recv throughput with the "old" offset/length API -'use strict'; - -const common = require('../common.js'); -const dgram = require('dgram'); -const PORT = common.PORT; - -// `num` is the number of send requests to queue up each time. -// Keep it reasonably high (>10) otherwise you're benchmarking the speed of -// event loop cycles more than anything else. -const bench = common.createBenchmark(main, { - len: [1, 64, 256, 1024], - num: [100], - type: ['send', 'recv'], - dur: [5] -}); - -function main({ dur, len, num, type }) { - const chunk = Buffer.allocUnsafe(len); - var sent = 0; - var received = 0; - const socket = dgram.createSocket('udp4'); - - function onsend() { - if (sent++ % num === 0) { - for (var i = 0; i < num; i++) { - socket.send(chunk, 0, chunk.length, PORT, '127.0.0.1', onsend); - } - } - } - - socket.on('listening', () => { - bench.start(); - onsend(); - - setTimeout(() => { - const bytes = (type === 'send' ? sent : received) * chunk.length; - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); - process.exit(0); - }, dur * 1000); - }); - - socket.on('message', () => { - received++; - }); - - socket.bind(PORT); -} diff --git a/deps/node/benchmark/dgram/single-buffer.js b/deps/node/benchmark/dgram/single-buffer.js deleted file mode 100644 index d183b9cd..00000000 --- a/deps/node/benchmark/dgram/single-buffer.js +++ /dev/null @@ -1,49 +0,0 @@ -// test UDP send/recv throughput with the new single Buffer API -'use strict'; - -const common = require('../common.js'); -const dgram = require('dgram'); -const PORT = common.PORT; - -// `num` is the number of send requests to queue up each time. -// Keep it reasonably high (>10) otherwise you're benchmarking the speed of -// event loop cycles more than anything else. -const bench = common.createBenchmark(main, { - len: [1, 64, 256, 1024], - num: [100], - type: ['send', 'recv'], - dur: [5] -}); - -function main({ dur, len, num, type }) { - const chunk = Buffer.allocUnsafe(len); - var sent = 0; - var received = 0; - const socket = dgram.createSocket('udp4'); - - function onsend() { - if (sent++ % num === 0) { - for (var i = 0; i < num; i++) { - socket.send(chunk, PORT, '127.0.0.1', onsend); - } - } - } - - socket.on('listening', () => { - bench.start(); - onsend(); - - setTimeout(() => { - const bytes = (type === 'send' ? sent : received) * chunk.length; - const gbits = (bytes * 8) / (1024 * 1024 * 1024); - bench.end(gbits); - process.exit(0); - }, dur * 1000); - }); - - socket.on('message', () => { - received++; - }); - - socket.bind(PORT); -} diff --git a/deps/node/benchmark/dns/lookup.js b/deps/node/benchmark/dns/lookup.js deleted file mode 100644 index 3cc228c5..00000000 --- a/deps/node/benchmark/dns/lookup.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const lookup = require('dns').lookup; - -const bench = common.createBenchmark(main, { - name: ['', '127.0.0.1', '::1'], - all: ['true', 'false'], - n: [5e6] -}); - -function main({ name, n, all }) { - var i = 0; - - if (all === 'true') { - const opts = { all: true }; - bench.start(); - (function cb() { - if (i++ === n) { - bench.end(n); - return; - } - lookup(name, opts, cb); - })(); - } else { - bench.start(); - (function cb() { - if (i++ === n) { - bench.end(n); - return; - } - lookup(name, cb); - })(); - } -} diff --git a/deps/node/benchmark/domain/domain-fn-args.js b/deps/node/benchmark/domain/domain-fn-args.js deleted file mode 100644 index c889b354..00000000 --- a/deps/node/benchmark/domain/domain-fn-args.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const domain = require('domain'); - -const bench = common.createBenchmark(main, { - args: [0, 1, 2, 3], - n: [10] -}); - -const bdomain = domain.create(); -const gargs = [1, 2, 3]; - -function main({ n, args }) { - const myArguments = gargs.slice(0, args); - bench.start(); - - bdomain.enter(); - for (var i = 0; i < n; i++) { - if (myArguments.length >= 2) { - const args = Array.prototype.slice.call(myArguments, 1); - fn.apply(this, args); - } else { - fn.call(this); - } - } - bdomain.exit(); - - bench.end(n); -} - -function fn(a = 1, b = 2, c = 3) { - return a + b + c; -} diff --git a/deps/node/benchmark/es/defaultparams-bench.js b/deps/node/benchmark/es/defaultparams-bench.js deleted file mode 100644 index c568c12a..00000000 --- a/deps/node/benchmark/es/defaultparams-bench.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - method: ['withoutdefaults', 'withdefaults'], - n: [1e8] -}); - -function oldStyleDefaults(x, y) { - x = x || 1; - y = y || 2; - assert.strictEqual(x, 1); - assert.strictEqual(y, 2); -} - -function defaultParams(x = 1, y = 2) { - assert.strictEqual(x, 1); - assert.strictEqual(y, 2); -} - -function runOldStyleDefaults(n) { - bench.start(); - for (var i = 0; i < n; i++) - oldStyleDefaults(); - bench.end(n); -} - -function runDefaultParams(n) { - bench.start(); - for (var i = 0; i < n; i++) - defaultParams(); - bench.end(n); -} - -function main({ n, method }) { - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'withoutdefaults': - runOldStyleDefaults(n); - break; - case 'withdefaults': - runDefaultParams(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/es/destructuring-bench.js b/deps/node/benchmark/es/destructuring-bench.js deleted file mode 100644 index 37f3fd9a..00000000 --- a/deps/node/benchmark/es/destructuring-bench.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - method: ['swap', 'destructure'], - n: [1e8] -}); - -function runSwapManual(n) { - var x, y, r; - bench.start(); - for (var i = 0; i < n; i++) { - x = 1, y = 2; - r = x; - x = y; - y = r; - assert.strictEqual(x, 2); - assert.strictEqual(y, 1); - } - bench.end(n); -} - -function runSwapDestructured(n) { - var x, y; - bench.start(); - for (var i = 0; i < n; i++) { - x = 1, y = 2; - [x, y] = [y, x]; - assert.strictEqual(x, 2); - assert.strictEqual(y, 1); - } - bench.end(n); -} - -function main({ n, method }) { - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'swap': - runSwapManual(n); - break; - case 'destructure': - runSwapDestructured(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/es/destructuring-object-bench.js b/deps/node/benchmark/es/destructuring-object-bench.js deleted file mode 100644 index 0c5615fd..00000000 --- a/deps/node/benchmark/es/destructuring-object-bench.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - method: ['normal', 'destructureObject'], - n: [1e8] -}); - -function runNormal(n) { - var i = 0; - const o = { x: 0, y: 1 }; - bench.start(); - for (; i < n; i++) { - /* eslint-disable no-unused-vars */ - const x = o.x; - const y = o.y; - const r = o.r || 2; - /* eslint-enable no-unused-vars */ - } - bench.end(n); -} - -function runDestructured(n) { - var i = 0; - const o = { x: 0, y: 1 }; - bench.start(); - for (; i < n; i++) { - /* eslint-disable no-unused-vars */ - const { x, y, r = 2 } = o; - /* eslint-enable no-unused-vars */ - } - bench.end(n); -} - -function main({ n, method }) { - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'normal': - runNormal(n); - break; - case 'destructureObject': - runDestructured(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/es/foreach-bench.js b/deps/node/benchmark/es/foreach-bench.js deleted file mode 100644 index 25ea97b4..00000000 --- a/deps/node/benchmark/es/foreach-bench.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - method: ['for', 'for-of', 'for-in', 'forEach'], - count: [5, 10, 20, 100], - n: [5e6] -}); - -function useFor(n, items, count) { - bench.start(); - for (var i = 0; i < n; i++) { - for (var j = 0; j < count; j++) { - /* eslint-disable no-unused-vars */ - const item = items[j]; - /* esline-enable no-unused-vars */ - } - } - bench.end(n); -} - -function useForOf(n, items) { - var item; - bench.start(); - for (var i = 0; i < n; i++) { - for (item of items) {} - } - bench.end(n); -} - -function useForIn(n, items) { - bench.start(); - for (var i = 0; i < n; i++) { - for (var j in items) { - /* eslint-disable no-unused-vars */ - const item = items[j]; - /* esline-enable no-unused-vars */ - } - } - bench.end(n); -} - -function useForEach(n, items) { - bench.start(); - for (var i = 0; i < n; i++) { - items.forEach((item) => {}); - } - bench.end(n); -} - -function main({ n, count, method }) { - const items = new Array(count); - var fn; - for (var i = 0; i < count; i++) - items[i] = i; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'for': - fn = useFor; - break; - case 'for-of': - fn = useForOf; - break; - case 'for-in': - fn = useForIn; - break; - case 'forEach': - fn = useForEach; - break; - default: - throw new Error(`Unexpected method "${method}"`); - } - fn(n, items, count); -} diff --git a/deps/node/benchmark/es/map-bench.js b/deps/node/benchmark/es/map-bench.js deleted file mode 100644 index a2f9e245..00000000 --- a/deps/node/benchmark/es/map-bench.js +++ /dev/null @@ -1,130 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - method: [ - 'object', 'nullProtoObject', 'nullProtoLiteralObject', 'storageObject', - 'fakeMap', 'map', - ], - n: [1e6] -}); - -function runObject(n) { - const m = {}; - bench.start(); - for (var i = 0; i < n; i++) { - m[`i${i}`] = i; - m[`s${i}`] = String(i); - assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); - m[`i${i}`] = undefined; - m[`s${i}`] = undefined; - } - bench.end(n); -} - -function runNullProtoObject(n) { - const m = Object.create(null); - bench.start(); - for (var i = 0; i < n; i++) { - m[`i${i}`] = i; - m[`s${i}`] = String(i); - assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); - m[`i${i}`] = undefined; - m[`s${i}`] = undefined; - } - bench.end(n); -} - -function runNullProtoLiteralObject(n) { - const m = { __proto__: null }; - bench.start(); - for (var i = 0; i < n; i++) { - m[`i${i}`] = i; - m[`s${i}`] = String(i); - assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); - m[`i${i}`] = undefined; - m[`s${i}`] = undefined; - } - bench.end(n); -} - -function StorageObject() {} -StorageObject.prototype = Object.create(null); - -function runStorageObject(n) { - const m = new StorageObject(); - bench.start(); - for (var i = 0; i < n; i++) { - m[`i${i}`] = i; - m[`s${i}`] = String(i); - assert.strictEqual(String(m[`i${i}`]), m[`s${i}`]); - m[`i${i}`] = undefined; - m[`s${i}`] = undefined; - } - bench.end(n); -} - -function fakeMap() { - const m = {}; - return { - get(key) { return m[`$${key}`]; }, - set(key, val) { m[`$${key}`] = val; }, - get size() { return Object.keys(m).length; }, - has(key) { return Object.prototype.hasOwnProperty.call(m, `$${key}`); } - }; -} - -function runFakeMap(n) { - const m = fakeMap(); - bench.start(); - for (var i = 0; i < n; i++) { - m.set(`i${i}`, i); - m.set(`s${i}`, String(i)); - assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); - m.set(`i${i}`, undefined); - m.set(`s${i}`, undefined); - } - bench.end(n); -} - -function runMap(n) { - const m = new Map(); - bench.start(); - for (var i = 0; i < n; i++) { - m.set(`i${i}`, i); - m.set(`s${i}`, String(i)); - assert.strictEqual(String(m.get(`i${i}`)), m.get(`s${i}`)); - m.set(`i${i}`, undefined); - m.set(`s${i}`, undefined); - } - bench.end(n); -} - -function main({ n, method }) { - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'object': - runObject(n); - break; - case 'nullProtoObject': - runNullProtoObject(n); - break; - case 'nullProtoLiteralObject': - runNullProtoLiteralObject(n); - break; - case 'storageObject': - runStorageObject(n); - break; - case 'fakeMap': - runFakeMap(n); - break; - case 'map': - runMap(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/es/restparams-bench.js b/deps/node/benchmark/es/restparams-bench.js deleted file mode 100644 index d9b4878c..00000000 --- a/deps/node/benchmark/es/restparams-bench.js +++ /dev/null @@ -1,71 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - method: ['copy', 'rest', 'arguments'], - n: [1e8] -}); - -function copyArguments() { - const len = arguments.length; - const args = new Array(len); - for (var i = 0; i < len; i++) - args[i] = arguments[i]; - assert.strictEqual(args[0], 1); - assert.strictEqual(args[1], 2); - assert.strictEqual(args[2], 'a'); - assert.strictEqual(args[3], 'b'); -} - -function restArguments(...args) { - assert.strictEqual(args[0], 1); - assert.strictEqual(args[1], 2); - assert.strictEqual(args[2], 'a'); - assert.strictEqual(args[3], 'b'); -} - -function useArguments() { - assert.strictEqual(arguments[0], 1); - assert.strictEqual(arguments[1], 2); - assert.strictEqual(arguments[2], 'a'); - assert.strictEqual(arguments[3], 'b'); -} - -function runCopyArguments(n) { - for (var i = 0; i < n; i++) - copyArguments(1, 2, 'a', 'b'); -} - -function runRestArguments(n) { - for (var i = 0; i < n; i++) - restArguments(1, 2, 'a', 'b'); -} - -function runUseArguments(n) { - for (var i = 0; i < n; i++) - useArguments(1, 2, 'a', 'b'); -} - -function main({ n, method }) { - var fn; - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'copy': - fn = runCopyArguments; - break; - case 'rest': - fn = runRestArguments; - break; - case 'arguments': - fn = runUseArguments; - break; - default: - throw new Error(`Unexpected method "${method}"`); - } - bench.start(); - fn(n); - bench.end(n); -} diff --git a/deps/node/benchmark/es/spread-assign.js b/deps/node/benchmark/es/spread-assign.js deleted file mode 100644 index bbe07e02..00000000 --- a/deps/node/benchmark/es/spread-assign.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const util = require('util'); - -const bench = common.createBenchmark(main, { - method: ['spread', 'assign', '_extend'], - count: [5, 10, 20], - n: [1e6] -}); - -function main({ n, context, count, rest, method }) { - - const src = {}; - for (let n = 0; n < count; n++) - src[`p${n}`] = n; - - let obj; // eslint-disable-line no-unused-vars - let i; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case '_extend': - bench.start(); - for (i = 0; i < n; i++) - obj = util._extend({}, src); - bench.end(n); - break; - case 'assign': - bench.start(); - for (i = 0; i < n; i++) - obj = Object.assign({}, src); - bench.end(n); - break; - case 'spread': - bench.start(); - for (i = 0; i < n; i++) - obj = { ...src }; - bench.end(n); - break; - default: - throw new Error('Unexpected method'); - } -} diff --git a/deps/node/benchmark/es/spread-bench.js b/deps/node/benchmark/es/spread-bench.js deleted file mode 100644 index 97c7596b..00000000 --- a/deps/node/benchmark/es/spread-bench.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - method: ['apply', 'spread', 'call-spread'], - count: [5, 10, 20], - context: ['context', 'null'], - rest: [0, 1], - n: [5e6] -}); - -function makeTest(count, rest) { - if (rest) { - return function test(...args) { - assert.strictEqual(count, args.length); - }; - } else { - return function test() { - assert.strictEqual(count, arguments.length); - }; - } -} - -function main({ n, context, count, rest, method }) { - const ctx = context === 'context' ? {} : null; - var fn = makeTest(count, rest); - const args = new Array(count); - var i; - for (i = 0; i < count; i++) - args[i] = i; - - switch (method) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'apply': - bench.start(); - for (i = 0; i < n; i++) - fn.apply(ctx, args); - bench.end(n); - break; - case 'spread': - if (ctx !== null) - fn = fn.bind(ctx); - bench.start(); - for (i = 0; i < n; i++) - fn(...args); - bench.end(n); - break; - case 'call-spread': - bench.start(); - for (i = 0; i < n; i++) - fn.call(ctx, ...args); - bench.end(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/es/string-concatenations.js b/deps/node/benchmark/es/string-concatenations.js deleted file mode 100644 index 72fb7f99..00000000 --- a/deps/node/benchmark/es/string-concatenations.js +++ /dev/null @@ -1,69 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const configs = { - n: [1e3], - mode: [ - 'multi-concat', - 'multi-join', - 'multi-template', - 'to-string-string', - 'to-string-concat', - 'to-string-template', - ], -}; - -const bench = common.createBenchmark(main, configs); - -function main({ n, mode }) { - const str = 'abc'; - const num = 123; - - let string; - - switch (mode) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'multi-concat': - bench.start(); - for (let i = 0; i < n; i++) - string = '...' + str + ', ' + num + ', ' + str + ', ' + num + '.'; - bench.end(n); - break; - case 'multi-join': - bench.start(); - for (let i = 0; i < n; i++) - string = ['...', str, ', ', num, ', ', str, ', ', num, '.'].join(''); - bench.end(n); - break; - case 'multi-template': - bench.start(); - for (let i = 0; i < n; i++) - string = `...${str}, ${num}, ${str}, ${num}.`; - bench.end(n); - break; - case 'to-string-string': - bench.start(); - for (let i = 0; i < n; i++) - string = String(num); - bench.end(n); - break; - case 'to-string-concat': - bench.start(); - for (let i = 0; i < n; i++) - string = '' + num; - bench.end(n); - break; - case 'to-string-template': - bench.start(); - for (let i = 0; i < n; i++) - string = `${num}`; - bench.end(n); - break; - default: - throw new Error(`Unexpected method "${mode}"`); - } - - return string; -} diff --git a/deps/node/benchmark/es/string-repeat.js b/deps/node/benchmark/es/string-repeat.js deleted file mode 100644 index 9e33e4ac..00000000 --- a/deps/node/benchmark/es/string-repeat.js +++ /dev/null @@ -1,40 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const common = require('../common.js'); - -const configs = { - n: [1e3], - mode: ['Array', 'repeat'], - encoding: ['ascii', 'utf8'], - size: [1e1, 1e3, 1e6], -}; - -const bench = common.createBenchmark(main, configs); - -function main({ n, size, encoding, mode }) { - const character = encoding === 'ascii' ? 'a' : '\ud83d\udc0e'; // '🐎' - - let str; - - switch (mode) { - case '': - // Empty string falls through to next line as default, mostly for tests. - case 'Array': - bench.start(); - for (let i = 0; i < n; i++) - str = new Array(size + 1).join(character); - bench.end(n); - break; - case 'repeat': - bench.start(); - for (let i = 0; i < n; i++) - str = character.repeat(size); - bench.end(n); - break; - default: - throw new Error(`Unexpected method "${mode}"`); - } - - assert.strictEqual([...str].length, size); -} diff --git a/deps/node/benchmark/events/ee-add-remove.js b/deps/node/benchmark/events/ee-add-remove.js deleted file mode 100644 index 2d20736b..00000000 --- a/deps/node/benchmark/events/ee-add-remove.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const events = require('events'); - -const bench = common.createBenchmark(main, { n: [1e6] }); - -function main({ n }) { - const ee = new events.EventEmitter(); - const listeners = []; - - var k; - for (k = 0; k < 10; k += 1) - listeners.push(() => {}); - - bench.start(); - for (var i = 0; i < n; i += 1) { - const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; - for (k = listeners.length; --k >= 0; /* empty */) { - ee.on(dummy, listeners[k]); - } - for (k = listeners.length; --k >= 0; /* empty */) { - ee.removeListener(dummy, listeners[k]); - } - } - bench.end(n); -} diff --git a/deps/node/benchmark/events/ee-emit.js b/deps/node/benchmark/events/ee-emit.js deleted file mode 100644 index 8f1c2761..00000000 --- a/deps/node/benchmark/events/ee-emit.js +++ /dev/null @@ -1,48 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { - n: [2e6], - argc: [0, 2, 4, 10], - listeners: [1, 5, 10], -}); - -function main({ n, argc, listeners }) { - const ee = new EventEmitter(); - - for (var k = 0; k < listeners; k += 1) - ee.on('dummy', () => {}); - - var i; - switch (argc) { - case 2: - bench.start(); - for (i = 0; i < n; i += 1) { - ee.emit('dummy', true, 5); - } - bench.end(n); - break; - case 4: - bench.start(); - for (i = 0; i < n; i += 1) { - ee.emit('dummy', true, 5, 10, false); - } - bench.end(n); - break; - case 10: - bench.start(); - for (i = 0; i < n; i += 1) { - ee.emit('dummy', true, 5, 10, false, 5, 'string', true, false, 11, 20); - } - bench.end(n); - break; - default: - bench.start(); - for (i = 0; i < n; i += 1) { - ee.emit('dummy'); - } - bench.end(n); - break; - } -} diff --git a/deps/node/benchmark/events/ee-listener-count-on-prototype.js b/deps/node/benchmark/events/ee-listener-count-on-prototype.js deleted file mode 100644 index d48e96a4..00000000 --- a/deps/node/benchmark/events/ee-listener-count-on-prototype.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [5e7] }); - -function main({ n }) { - const ee = new EventEmitter(); - - for (var k = 0; k < 5; k += 1) { - ee.on('dummy0', () => {}); - ee.on('dummy1', () => {}); - } - - bench.start(); - for (var i = 0; i < n; i += 1) { - const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; - ee.listenerCount(dummy); - } - bench.end(n); -} diff --git a/deps/node/benchmark/events/ee-listeners-many.js b/deps/node/benchmark/events/ee-listeners-many.js deleted file mode 100644 index 7f9099c4..00000000 --- a/deps/node/benchmark/events/ee-listeners-many.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [5e6] }); - -function main({ n }) { - const ee = new EventEmitter(); - ee.setMaxListeners(101); - - for (var k = 0; k < 50; k += 1) { - ee.on('dummy0', () => {}); - ee.on('dummy1', () => {}); - } - - bench.start(); - for (var i = 0; i < n; i += 1) { - const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; - ee.listeners(dummy); - } - bench.end(n); -} diff --git a/deps/node/benchmark/events/ee-listeners.js b/deps/node/benchmark/events/ee-listeners.js deleted file mode 100644 index 74b88b04..00000000 --- a/deps/node/benchmark/events/ee-listeners.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [5e6] }); - -function main({ n }) { - const ee = new EventEmitter(); - - for (var k = 0; k < 5; k += 1) { - ee.on('dummy0', () => {}); - ee.on('dummy1', () => {}); - } - - bench.start(); - for (var i = 0; i < n; i += 1) { - const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; - ee.listeners(dummy); - } - bench.end(n); -} diff --git a/deps/node/benchmark/events/ee-once.js b/deps/node/benchmark/events/ee-once.js deleted file mode 100644 index e1a09fb4..00000000 --- a/deps/node/benchmark/events/ee-once.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const EventEmitter = require('events').EventEmitter; - -const bench = common.createBenchmark(main, { n: [2e7] }); - -function main({ n }) { - const ee = new EventEmitter(); - - function listener() {} - - bench.start(); - for (var i = 0; i < n; i += 1) { - const dummy = (i % 2 === 0) ? 'dummy0' : 'dummy1'; - ee.once(dummy, listener); - ee.emit(dummy); - } - bench.end(n); -} diff --git a/deps/node/benchmark/fixtures/alice.html b/deps/node/benchmark/fixtures/alice.html deleted file mode 100644 index a794e258..00000000 --- a/deps/node/benchmark/fixtures/alice.html +++ /dev/null @@ -1,3865 +0,0 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>The Project Gutenberg Etext of Alice's Adventures in Wonderland, by Lewis Carroll</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css"><!-- body{margin:10%;text-align:justify}p.asterisks{font-size:150%;font-family:monospace;text-align:center}--></style> </head><body><pre> -The Project Gutenberg Etext of Alice's Adventures in Wonderland -This is an HTML reprint of #1 in our series by Lewis Carroll - - -Copyright laws are changing all over the world, be sure to check -the copyright laws for your country before posting these files!! - -Please take a look at the important information in this header. -We encourage you to keep this file on your own disk, keeping an -electronic path open for the next readers. Do not remove this. - - -**Welcome To The World of Free Plain Vanilla Electronic Texts** - -**Etexts Readable By Both Humans and By Computers, Since 1971** - -*These Etexts Prepared By Hundreds of Volunteers and Donations* - -Information on contacting Project Gutenberg to get Etexts, and -further information is included below. We need your donations. - - -Alice's Adventures in Wonderland - -[Also known as "Alice in Wonderland"] - -by Lewis Carroll - -May, 1997 [Etext #928] -[Date last updated: April 15, 2005] - - -The Project Gutenberg Etext of Alice's Adventures in Wonderland -*****This file should be named alice30h.htm or alice30h.zip**** - -Corrected EDITIONS of our etexts get a new NUMBER, alice31h.htm. - - -This etext was prepared by James Rose, Granada Hills, CA. - - -We are now trying to release all our books one month in advance -of the official release dates, for time for better editing. - -Please note: neither this list nor its contents are final till -midnight of the last day of the month of any such announcement. -The official release date of all Project Gutenberg Etexts is at -Midnight, Central Time, of the last day of the stated month. A -preliminary version may often be posted for suggestion, comment -and editing by those who wish to do so. To be sure you have an -up to date first edition [xxxxx10x.xxx] please check file sizes -in the first week of the next month. Since our ftp program has -a bug in it that scrambles the date [tried to fix and failed] a -look at the file size will have to do, but we will try to see a -new copy has at least one byte more or less. - - -Information about Project Gutenberg (one page) - -We produce about two million dollars for each hour we work. The -fifty hours is one conservative estimate for how long it we take -to get any etext selected, entered, proofread, edited, copyright -searched and analyzed, the copyright letters written, etc. This -projected audience is one hundred million readers. If our value -per text is nominally estimated at one dollar then we produce $2 -million dollars per hour this year as we release thirty-two text -files per month: or 400 more Etexts in 1996 for a total of 800. -If these reach just 10% of the computerized population, then the -total should reach 80 billion Etexts. - -The Goal of Project Gutenberg is to Give Away One Trillion Etext -Files by the December 31, 2001. [10,000 x 100,000,000=Trillion] -This is ten thousand titles each to one hundred million readers, -which is only 10% of the present number of computer users. 2001 -should have at least twice as many computer users as that, so it -will require us reaching less than 5% of the users in 2001. - - -We need your donations more than ever! - - -All donations should be made to "Project Gutenberg/CMU": and are -tax deductible to the extent allowable by law. (CMU = Carnegie -Mellon University). - -For these and other matters, please mail to: - -Project Gutenberg -P. O. Box 2782 -Champaign, IL 61825 - -When all other email fails try our Executive Director: -Michael S. Hart [hart@pobox.com] - -We would prefer to send you this information by email -(Internet, Bitnet, Compuserve, ATTMAIL or MCImail). - -****** -If you have an FTP program (or emulator), please -FTP directly to the Project Gutenberg archives: -[Mac users, do NOT point and click. . .type] - -ftp uiarchive.cso.uiuc.edu -login: anonymous -password: your@login -cd etext/etext90 through /etext96 -or cd etext/articles [get suggest gut for more information] -dir [to see files] -get or mget [to get files. . .set bin for zip files] -GET INDEX?00.GUT -for a list of books -and -GET NEW GUT for general information -and -MGET GUT* for newsletters. - -**Information prepared by the Project Gutenberg legal advisor** -(Three Pages) - - -***START**THE SMALL PRINT!**FOR PUBLIC DOMAIN ETEXTS**START*** -Why is this "Small Print!" statement here? You know: lawyers. -They tell us you might sue us if there is something wrong with -your copy of this etext, even if you got it for free from -someone other than us, and even if what's wrong is not our -fault. So, among other things, this "Small Print!" statement -disclaims most of our liability to you. It also tells you how -you can distribute copies of this etext if you want to. - -*BEFORE!* YOU USE OR READ THIS ETEXT -By using or reading any part of this PROJECT GUTENBERG-tm -etext, you indicate that you understand, agree to and accept -this "Small Print!" statement. If you do not, you can receive -a refund of the money (if any) you paid for this etext by -sending a request within 30 days of receiving it to the person -you got it from. If you received this etext on a physical -medium (such as a disk), you must return it with your request. - -ABOUT PROJECT GUTENBERG-TM ETEXTS -This PROJECT GUTENBERG-tm etext, like most PROJECT GUTENBERG- -tm etexts, is a "public domain" work distributed by Professor -Michael S. Hart through the Project Gutenberg Association at -Carnegie-Mellon University (the "Project"). Among other -things, this means that no one owns a United States copyright -on or for this work, so the Project (and you!) can copy and -distribute it in the United States without permission and -without paying copyright royalties. Special rules, set forth -below, apply if you wish to copy and distribute this etext -under the Project's "PROJECT GUTENBERG" trademark. - -To create these etexts, the Project expends considerable -efforts to identify, transcribe and proofread public domain -works. Despite these efforts, the Project's etexts and any -medium they may be on may contain "Defects". Among other -things, Defects may take the form of incomplete, inaccurate or -corrupt data, transcription errors, a copyright or other -intellectual property infringement, a defective or damaged -disk or other etext medium, a computer virus, or computer -codes that damage or cannot be read by your equipment. - -LIMITED WARRANTY; DISCLAIMER OF DAMAGES -But for the "Right of Replacement or Refund" described below, -[1] the Project (and any other party you may receive this -etext from as a PROJECT GUTENBERG-tm etext) disclaims all -liability to you for damages, costs and expenses, including -legal fees, and [2] YOU HAVE NO REMEDIES FOR NEGLIGENCE OR -UNDER STRICT LIABILITY, OR FOR BREACH OF WARRANTY OR CONTRACT, -INCLUDING BUT NOT LIMITED TO INDIRECT, CONSEQUENTIAL, PUNITIVE -OR INCIDENTAL DAMAGES, EVEN IF YOU GIVE NOTICE OF THE -POSSIBILITY OF SUCH DAMAGES. - -If you discover a Defect in this etext within 90 days of -receiving it, you can receive a refund of the money (if any) -you paid for it by sending an explanatory note within that -time to the person you received it from. If you received it -on a physical medium, you must return it with your note, and -such person may choose to alternatively give you a replacement -copy. If you received it electronically, such person may -choose to alternatively give you a second opportunity to -receive it electronically. - -THIS ETEXT IS OTHERWISE PROVIDED TO YOU "AS-IS". NO OTHER -WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, ARE MADE TO YOU AS -TO THE ETEXT OR ANY MEDIUM IT MAY BE ON, INCLUDING BUT NOT -LIMITED TO WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A -PARTICULAR PURPOSE. - -Some states do not allow disclaimers of implied warranties or -the exclusion or limitation of consequential damages, so the -above disclaimers and exclusions may not apply to you, and you -may have other legal rights. - -INDEMNITY -You will indemnify and hold the Project, its directors, -officers, members and agents harmless from all liability, cost -and expense, including legal fees, that arise directly or -indirectly from any of the following that you do or cause: -[1] distribution of this etext, [2] alteration, modification, -or addition to the etext, or [3] any Defect. - -DISTRIBUTION UNDER "PROJECT GUTENBERG-tm" -You may distribute copies of this etext electronically, or by -disk, book or any other medium if you either delete this -"Small Print!" and all other references to Project Gutenberg, -or: - -[1] Only give exact copies of it. Among other things, this - requires that you do not remove, alter or modify the - etext or this "small print!" statement. You may however, - if you wish, distribute this etext in machine readable - binary, compressed, mark-up, or proprietary form, - including any form resulting from conversion by word pro- - cessing or hypertext software, but only so long as - *EITHER*: - - [*] The etext, when displayed, is clearly readable, and - does *not* contain characters other than those - intended by the author of the work, although tilde - (~), asterisk (*) and underline (_) characters may - be used to convey punctuation intended by the - author, and additional characters may be used to - indicate hypertext links; OR - - [*] The etext may be readily converted by the reader at - no expense into plain ASCII, EBCDIC or equivalent - form by the program that displays the etext (as is - the case, for instance, with most word processors); - OR - - [*] You provide, or agree to also provide on request at - no additional cost, fee or expense, a copy of the - etext in its original plain ASCII form (or in EBCDIC - or other equivalent proprietary form). - -[2] Honor the etext refund and replacement provisions of this - "Small Print!" statement. - -[3] Pay a trademark license fee to the Project of 20% of the - net profits you derive calculated using the method you - already use to calculate your applicable taxes. If you - don't derive profits, no royalty is due. Royalties are - payable to "Project Gutenberg Association/Carnegie-Mellon - University" within the 60 days following each - date you prepare (or were legally required to prepare) - your annual (or equivalent periodic) tax return. - -WHAT IF YOU *WANT* TO SEND MONEY EVEN IF YOU DON'T HAVE TO? -The Project gratefully accepts contributions in money, time, -scanning machines, OCR software, public domain etexts, royalty -free copyright licenses, and every other sort of contribution -you can think of. Money should be paid to "Project Gutenberg -Association / Carnegie-Mellon University". - -*END*THE SMALL PRINT! FOR PUBLIC DOMAIN ETEXTS*Ver.04.29.93*END* - - - - - -</pre> - -<hr> -<h1 align="Center">ALICE'S ADVENTURES IN WONDERLAND</h1> - -<h3 align="Center">Lewis Carroll</h3> - -<p align="Center"><i>THE MILLENNIUM FULCRUM EDITION 3.0</i></p> - -<hr> -<h3 align="Center">CHAPTER I</h3> - -<h3 align="Center">Down the Rabbit-Hole</h3> - -<p>Alice was beginning to get very tired of sitting by her sister -on the bank, and of having nothing to do: once or twice she had -peeped into the book her sister was reading, but it had no -pictures or conversations in it, 'and what is the use of a book,' -thought Alice 'without pictures or conversation?'</p> - -<p>So she was considering in her own mind (as well as she could, -for the hot day made her feel very sleepy and stupid), whether -the pleasure of making a daisy-chain would be worth the trouble -of getting up and picking the daisies, when suddenly a White -Rabbit with pink eyes ran close by her.</p> - -<p>There was nothing so <i>very</i> remarkable in that; nor did -Alice think it so <i>very</i> much out of the way to hear the -Rabbit say to itself, 'Oh dear! Oh dear! I shall be late!' (when -she thought it over afterwards, it occurred to her that she ought -to have wondered at this, but at the time it all seemed quite -natural); but when the Rabbit actually <i>took a watch out of its -waistcoat-pocket,</i> and looked at it, and then hurried on, -Alice started to her feet, for it flashed across her mind that -she had never before seen a rabbit with either a -waistcoat-pocket, or a watch to take out of it, and burning with -curiosity, she ran across the field after it, and fortunately was -just in time to see it pop down a large rabbit-hole under the -hedge.</p> - -<p>In another moment down went Alice after it, never once -considering how in the world she was to get out again.</p> - -<p>The rabbit-hole went straight on like a tunnel for some way, -and then dipped suddenly down, so suddenly that Alice had not a -moment to think about stopping herself before she found herself -falling down a very deep well.</p> - -<p>Either the well was very deep, or she fell very slowly, for -she had plenty of time as she went down to look about her and to -wonder what was going to happen next. First, she tried to look -down and make out what she was coming to, but it was too dark to -see anything; then she looked at the sides of the well, and -noticed that they were filled with cupboards and book-shelves; -here and there she saw maps and pictures hung upon pegs. She took -down a jar from one of the shelves as she passed; it was labelled -'ORANGE MARMALADE', but to her great disappointment it was empty: -she did not like to drop the jar for fear of killing somebody, so -managed to put it into one of the cupboards as she fell past -it.</p> - -<p>'Well!' thought Alice to herself, 'after such a fall as this, -I shall think nothing of tumbling down stairs! How brave they'll -all think me at home! Why, I wouldn't say anything about it, even -if I fell off the top of the house!' (Which was very likely -true.)</p> - -<p>Down, down, down. Would the fall <i>never</i> come to an end! -'I wonder how many miles I've fallen by this time?' she said -aloud. 'I must be getting somewhere near the centre of the earth. -Let me see: that would be four thousand miles down, I think--' -(for, you see, Alice had learnt several things of this sort in -her lessons in the schoolroom, and though this was not a <i>very</i> -good opportunity for showing off her knowledge, as there was no -one to listen to her, still it was good practice to say it over) -'--yes, that's about the right distance--but then I wonder what -Latitude or Longitude I've got to?' (Alice had no idea what -Latitude was, or Longitude either, but thought they were nice -grand words to say.)</p> - -<p>Presently she began again. 'I wonder if I shall fall right -<i>through</i> the earth! How funny it'll seem to come out among -the people that walk with their heads downward! The Antipathies, -I think--' (she was rather glad there <i>was</i> no one listening, this -time, as it didn't sound at all the right word) '--but I shall -have to ask them what the name of the country is, you know. -Please, Ma'am, is this New Zealand or Australia?' (and she tried -to curtsey as she spoke--fancy <i>curtseying</i> as you're -falling through the air! Do you think you could manage it?) 'And -what an ignorant little girl she'll think me for asking! No, -it'll never do to ask: perhaps I shall see it written up -somewhere.'</p> - -<p>Down, down, down. There was nothing else to do, so Alice soon -began talking again. 'Dinah'll miss me very much to-night, I -should think!' (Dinah was the cat.) 'I hope they'll remember her -saucer of milk at tea-time. Dinah my dear! I wish you were down -here with me! There are no mice in the air, I'm afraid, but you -might catch a bat, and that's very like a mouse, you know. But do -cats eat bats, I wonder?' And here Alice began to get rather -sleepy, and went on saying to herself, in a dreamy sort of way, -'Do cats eat bats? Do cats eat bats?' and sometimes, 'Do bats eat -cats?' for, you see, as she couldn't answer either question, it -didn't much matter which way she put it. She felt that she was -dozing off, and had just begun to dream that she was walking hand -in hand with Dinah, and saying to her very earnestly, 'Now, -Dinah, tell me the truth: did you ever eat a bat?' when suddenly, -thump! thump! down she came upon a heap of sticks and dry leaves, -and the fall was over.</p> - -<p>Alice was not a bit hurt, and she jumped up on to her feet in -a moment: she looked up, but it was all dark overhead; before her -was another long passage, and the White Rabbit was still in -sight, hurrying down it. There was not a moment to be lost: away -went Alice like the wind, and was just in time to hear it say, as -it turned a corner, 'Oh my ears and whiskers, how late it's -getting!' She was close behind it when she turned the corner, but -the Rabbit was no longer to be seen: she found herself in a long, -low hall, which was lit up by a row of lamps hanging from the -roof.</p> - -<p>There were doors all round the hall, but they were all locked; -and when Alice had been all the way down one side and up the -other, trying every door, she walked sadly down the middle, -wondering how she was ever to get out again.</p> - -<p>Suddenly she came upon a little three-legged table, all made -of solid glass; there was nothing on it except a tiny golden key, -and Alice's first thought was that it might belong to one of the -doors of the hall; but, alas! either the locks were too large, or -the key was too small, but at any rate it would not open any of -them. However, on the second time round, she came upon a low -curtain she had not noticed before, and behind it was a little -door about fifteen inches high: she tried the little golden key -in the lock, and to her great delight it fitted!</p> - -<p>Alice opened the door and found that it led into a small -passage, not much larger than a rat-hole: she knelt down and -looked along the passage into the loveliest garden you ever saw. -How she longed to get out of that dark hall, and wander about -among those beds of bright flowers and those cool fountains, but -she could not even get her head though the doorway; 'and even if -my head <i>would</i> go through,' thought poor Alice, 'it would -be of very little use without my shoulders. Oh, how I wish I -could shut up like a telescope! I think I could, if I only know -how to begin.' For, you see, so many out-of-the-way things had -happened lately, that Alice had begun to think that very few -things indeed were really impossible.</p> - -<p>There seemed to be no use in waiting by the little door, so -she went back to the table, half hoping she might find another -key on it, or at any rate a book of rules for shutting people up -like telescopes: this time she found a little bottle on it, -('which certainly was not here before,' said Alice,) and round -the neck of the bottle was a paper label, with the words 'DRINK -ME' beautifully printed on it in large letters.</p> - -<p>It was all very well to say 'Drink me,' but the wise little -Alice was not going to do <i>that</i> in a hurry. 'No, I'll look -first,' she said, 'and see whether it's marked "<i>poison</i>" or -not'; for she had read several nice little histories about -children who had got burnt, and eaten up by wild beasts and other -unpleasant things, all because they <i>would</i> not remember the -simple rules their friends had taught them: such as, that a -red-hot poker will burn you if you hold it too long; and that if -you cut your finger <i>very</i> deeply with a knife, it usually -bleeds; and she had never forgotten that, if you drink much from -a bottle marked '<i>poison</i>,' it is almost certain to disagree -with you, sooner or later.</p> - -<p>However, this bottle was <i>not</i> marked 'poison,' so Alice -ventured to taste it, and finding it very nice, (it had, in fact, -a sort of mixed flavour of cherry-tart, custard, pine-apple, -roast turkey, toffee, and hot buttered toast,) she very soon -finished it off.</p> - -<p class="asterisks"> -<br> -* * * * * -<br> -* * * * -<br> -* * * * * -<br> -</p> - -<p>'What a curious feeling!' said Alice; 'I must be shutting up -like a telescope.'</p> - -<p>And so it was indeed: she was now only ten inches high, and -her face brightened up at the thought that she was now the right -size for going through the little door into that lovely garden. -First, however, she waited for a few minutes to see if she was -going to shrink any further: she felt a little nervous about -this; 'for it might end, you know,' said Alice to herself, 'in my -going out altogether, like a candle. I wonder what I should be -like then?' And she tried to fancy what the flame of a candle is -like after the candle is blown out, for she could not remember -ever having seen such a thing.</p> - -<p>After a while, finding that nothing more happened, she decided -on going into the garden at once; but, alas for poor Alice! when -she got to the door, she found she had forgotten the little -golden key, and when she went back to the table for it, she found -she could not possibly reach it: she could see it quite plainly -through the glass, and she tried her best to climb up one of the -legs of the table, but it was too slippery; and when she had -tired herself out with trying, the poor little thing sat down and -cried.</p> - -<p>'Come, there's no use in crying like that!' said Alice to -herself, rather sharply; 'I advise you to leave off this minute!' -She generally gave herself very good advice, (though she very -seldom followed it), and sometimes she scolded herself so -severely as to bring tears into her eyes; and once she remembered -trying to box her own ears for having cheated herself in a game -of croquet she was playing against herself, for this curious -child was very fond of pretending to be two people. 'But it's no -use now,' thought poor Alice, 'to pretend to be two people! Why, -there's hardly enough of me left to make <i>one</i> respectable -person!'</p> - -<p>Soon her eye fell on a little glass box that was lying under -the table: she opened it, and found in it a very small cake, on -which the words 'EAT ME' were beautifully marked in currants. -'Well, I'll eat it,' said Alice, 'and if it makes me grow larger, -I can reach the key; and if it makes me grow smaller, I can creep -under the door; so either way I'll get into the garden, and I -don't care which happens!'</p> - -<p>She ate a little bit, and said anxiously to herself, 'Which -way? Which way?', holding her hand on the top of her head to feel -which way it was growing, and she was quite surprised to find -that she remained the same size: to be sure, this generally -happens when one eats cake, but Alice had got so much into the -way of expecting nothing but out-of-the-way things to happen, -that it seemed quite dull and stupid for life to go on in the -common way.</p> - -<p>So she set to work, and very soon finished off the cake.</p> - -<p class="asterisks"> -<br> -* * * * * -<br> -* * * * -<br> -* * * * * -<br> -</p> - -<hr> -<h3 align="Center">CHAPTER II</h3> - -<h3 align="Center">The Pool of Tears</h3> - -<p>'Curiouser and curiouser!' cried Alice (she was so much -surprised, that for the moment she quite forgot how to speak good -English); 'now I'm opening out like the largest telescope that -ever was! Good-bye, feet!' (for when she looked down at her feet, -they seemed to be almost out of sight, they were getting so far -off). 'Oh, my poor little feet, I wonder who will put on your -shoes and stockings for you now, dears? I'm sure <i>I</i> shan't -be able! I shall be a great deal too far off to trouble myself -about you: you must manage the best way you can; --but I must be -kind to them,' thought Alice, 'or perhaps they won't walk the way -I want to go! Let me see: I'll give them a new pair of boots -every Christmas.'</p> - -<p>And she went on planning to herself how she would manage it. -'They must go by the carrier,' she thought; 'and how funny it'll -seem, sending presents to one's own feet! And how odd the -directions will look!</p> - -<blockquote><i>ALICE'S RIGHT FOOT, ESQ.</i> -<p><i>HEARTHRUG,</i></p> - -<p><i>NEAR THE FENDER,</i></p> - -<p><i>(WITH ALICE'S LOVE).</i></p> -</blockquote> - -<p>Oh dear, what nonsense I'm talking!'</p> - -<p>Just then her head struck against the roof of the hall: in -fact she was now more than nine feet high, and she at once took -up the little golden key and hurried off to the garden door.</p> - -<p>Poor Alice! It was as much as she could do, lying down on one -side, to look through into the garden with one eye; but to get -through was more hopeless than ever: she sat down and began to -cry again.</p> - -<p>'You ought to be ashamed of yourself,' said Alice, 'a great -girl like you,' (she might well say this), 'to go on crying in -this way! Stop this moment, I tell you!' But she went on all the -same, shedding gallons of tears, until there was a large pool all -round her, about four inches deep and reaching half down the -hall.</p> - -<p>After a time she heard a little pattering of feet in the -distance, and she hastily dried her eyes to see what was coming. -It was the White Rabbit returning, splendidly dressed, with a -pair of white kid gloves in one hand and a large fan in the -other: he came trotting along in a great hurry, muttering to -himself as he came, 'Oh! the Duchess, the Duchess! Oh! -<i>won't</i> she be savage if I've kept her waiting!' Alice felt -so desperate that she was ready to ask help of any one; so, when -the Rabbit came near her, she began, in a low, timid voice, 'If -you please, sir--' The Rabbit started violently, dropped the -white kid gloves and the fan, and skurried away into the darkness -as hard as he could go.</p> - -<p>Alice took up the fan and gloves, and, as the hall was very -hot, she kept fanning herself all the time she went on talking: -'Dear, dear! How queer everything is to-day! And yesterday things -went on just as usual. I wonder if I've been changed in the -night? Let me think: <i>was</i> I the same when I got up this -morning? I almost think I can remember feeling a little -different. But if I'm not the same, the next question is, Who in -the world am I? Ah, <i>that's</i> the great puzzle!' And she -began thinking over all the children she knew that were of the -same age as herself, to see if she could have been changed for -any of them.</p> - -<p>'I'm sure I'm not Ada,' she said, 'for her hair goes in such -long ringlets, and mine doesn't go in ringlets at all; and I'm -sure I can't be Mabel, for I know all sorts of things, and she, -oh! she knows such a very little! Besides, <i>she's</i> she, and -<i>I'm</i> I, and--oh dear, how puzzling it all is! I'll try if I -know all the things I used to know. Let me see: four times five -is twelve, and four times six is thirteen, and four times seven -is--oh dear! I shall never get to twenty at that rate! However, -the Multiplication Table doesn't signify: let's try Geography. -London is the capital of Paris, and Paris is the capital of Rome, -and Rome--no, <i>that's</i> all wrong, I'm certain! I must have -been changed for Mabel! I'll try and say "<i>How doth the -little--</i>"' and she crossed her hands on her lap as if she -were saying lessons, and began to repeat it, but her voice -sounded hoarse and strange, and the words did not come the same -as they used to do:--</p> - -<blockquote><i>'How doth the little crocodile</i> -<p><i>Improve his shining tail,</i></p> - -<p><i>And pour the waters of the Nile</i></p> - -<p><i>On every golden scale!</i></p> - -<p><i><br> -'How cheerfully he seems to grin,</i></p> - -<p><i>How neatly spread his claws,</i></p> - -<p><i>And welcome little fishes in</i></p> - -<p><i>With gently smiling jaws!</i>'</p> -</blockquote> - -<p>'I'm sure those are not the right words,' said poor Alice, and -her eyes filled with tears again as she went on, 'I must be Mabel -after all, and I shall have to go and live in that poky little -house, and have next to no toys to play with, and oh! ever so -many lessons to learn! No, I've made up my mind about it; if I'm -Mabel, I'll stay down here! It'll be no use their putting their -heads down and saying "Come up again, dear!" I shall only look up -and say "Who am I then? Tell me that first, and then, if I like -being that person, I'll come up: if not, I'll stay down here till -I'm somebody else"--but, oh dear!' cried Alice, with a sudden -burst of tears, 'I do wish they <i>would</i> put their heads -down! I am so <i>very</i> tired of being all alone here!'</p> - -<p>As she said this she looked down at her hands, and was -surprised to see that she had put on one of the Rabbit's little -white kid gloves while she was talking. 'How <i>can</i> I have -done that?' she thought. 'I must be growing small again.' She got -up and went to the table to measure herself by it, and found -that, as nearly as she could guess, she was now about two feet -high, and was going on shrinking rapidly: she soon found out that -the cause of this was the fan she was holding, and she dropped it -hastily, just in time to avoid shrinking away altogether.</p> - -<p>'That <i>was</i> a narrow escape!' said Alice, a good deal -frightened at the sudden change, but very glad to find herself -still in existence; 'and now for the garden!' and she ran with -all speed back to the little door: but, alas! the little door was -shut again, and the little golden key was lying on the glass -table as before, 'and things are worse than ever,' thought the -poor child, 'for I never was so small as this before, never! And -I declare it's too bad, that it is!'</p> - -<p>As she said these words her foot slipped, and in another -moment, splash! she was up to her chin in salt water. Her first -idea was that she had somehow fallen into the sea, 'and in that -case I can go back by railway,' she said to herself. (Alice had -been to the seaside once in her life, and had come to the general -conclusion, that wherever you go to on the English coast you find -a number of bathing machines in the sea, some children digging in -the sand with wooden spades, then a row of lodging houses, and -behind them a railway station.) However, she soon made out that -she was in the pool of tears which she had wept when she was nine -feet high.</p> - -<p>'I wish I hadn't cried so much!' said Alice, as she swam -about, trying to find her way out. 'I shall be punished for it -now, I suppose, by being drowned in my own tears! That -<i>will</i> be a queer thing, to be sure! However, everything is -queer to-day.'</p> - -<p>Just then she heard something splashing about in the pool a -little way off, and she swam nearer to make out what it was: at -first she thought it must be a walrus or hippopotamus, but then -she remembered how small she was now, and she soon made out that -it was only a mouse that had slipped in like herself.</p> - -<p>'Would it be of any use, now,' thought Alice, 'to speak to -this mouse? Everything is so out-of-the-way down here, that I -should think very likely it can talk: at any rate, there's no -harm in trying.' So she began: 'O Mouse, do you know the way out -of this pool? I am very tired of swimming about here, O Mouse!' -(Alice thought this must be the right way of speaking to a mouse: -she had never done such a thing before, but she remembered having -seen in her brother's Latin Grammar, 'A mouse--of a mouse--to a -mouse--a mouse--O mouse!') The Mouse looked at her rather -inquisitively, and seemed to her to wink with one of its little -eyes, but it said nothing.</p> - -<p>'Perhaps it doesn't understand English,' thought Alice; 'I -daresay it's a French mouse, come over with William the -Conqueror.' (For, with all her knowledge of history, Alice had no -very clear notion how long ago anything had happened.) So she -began again: 'Ou est ma chatte?' which was the first sentence in -her French lesson-book. The Mouse gave a sudden leap out of the -water, and seemed to quiver all over with fright. 'Oh, I beg your -pardon!' cried Alice hastily, afraid that she had hurt the poor -animal's feelings. 'I quite forgot you didn't like cats.'</p> - -<p>'Not like cats!' cried the Mouse, in a shrill, passionate -voice. 'Would <i>you</i> like cats if you were me?'</p> - -<p>'Well, perhaps not,' said Alice in a soothing tone: 'don't be -angry about it. And yet I wish I could show you our cat Dinah: I -think you'd take a fancy to cats if you could only see her. She -is such a dear quiet thing,' Alice went on, half to herself, as -she swam lazily about in the pool, 'and she sits purring so -nicely by the fire, licking her paws and washing her face--and -she is such a nice soft thing to nurse--and she's such a capital -one for catching mice--oh, I beg your pardon!' cried Alice again, -for this time the Mouse was bristling all over, and she felt -certain it must be really offended. 'We won't talk about her any -more if you'd rather not.'</p> - -<p>'We indeed!' cried the Mouse, who was trembling down to the -end of his tail. 'As if I would talk on such a subject! Our -family always <i>hated</i> cats: nasty, low, vulgar things! Don't -let me hear the name again!'</p> - -<p>'I won't indeed!' said Alice, in a great hurry to change the -subject of conversation. 'Are you--are you fond--of--of dogs?' -The Mouse did not answer, so Alice went on eagerly: 'There is -such a nice little dog near our house I should like to show you! -A little bright-eyed terrier, you know, with oh, such long curly -brown hair! And it'll fetch things when you throw them, and it'll -sit up and beg for its dinner, and all sorts of things--I can't -remember half of them--and it belongs to a farmer, you know, and -he says it's so useful, it's worth a hundred pounds! He says it -kills all the rats and--oh dear!' cried Alice in a sorrowful -tone, 'I'm afraid I've offended it again!' For the Mouse was -swimming away from her as hard as it could go, and making quite a -commotion in the pool as it went.</p> - -<p>So she called softly after it, 'Mouse dear! Do come back -again, and we won't talk about cats or dogs either, if you don't -like them!' When the Mouse heard this, it turned round and swam -slowly back to her: its face was quite pale (with passion, Alice -thought), and it said in a low trembling voice, 'Let us get to -the shore, and then I'll tell you my history, and you'll -understand why it is I hate cats and dogs.'</p> - -<p>It was high time to go, for the pool was getting quite crowded -with the birds and animals that had fallen into it: there were a -Duck and a Dodo, a Lory and an Eaglet, and several other curious -creatures. Alice led the way, and the whole party swam to the -shore.</p> - -<hr> -<h3 align="Center">CHAPTER III</h3> - -<h3 align="Center">A Caucus-Race and a Long Tale</h3> - -<p>They were indeed a queer-looking party that assembled on the -bank--the birds with draggled feathers, the animals with their -fur clinging close to them, and all dripping wet, cross, and -uncomfortable.</p> - -<p>The first question of course was, how to get dry again: they -had a consultation about this, and after a few minutes it seemed -quite natural to Alice to find herself talking familiarly with -them, as if she had known them all her life. Indeed, she had -quite a long argument with the Lory, who at last turned sulky, -and would only say, 'I am older than you, and must know better'; -and this Alice would not allow without knowing how old it was, -and, as the Lory positively refused to tell its age, there was no -more to be said.</p> - -<p>At last the Mouse, who seemed to be a person of authority -among them, called out, 'Sit down, all of you, and listen to me! -<i>I'll</i> soon make you dry enough!' They all sat down at once, -in a large ring, with the Mouse in the middle. Alice kept her -eyes anxiously fixed on it, for she felt sure she would catch a -bad cold if she did not get dry very soon.</p> - -<p>'Ahem!' said the Mouse with an important air, 'are you all -ready? This is the driest thing I know. Silence all round, if you -please! "William the Conqueror, whose cause was favoured by the -pope, was soon submitted to by the English, who wanted leaders, -and had been of late much accustomed to usurpation and conquest. -Edwin and Morcar, the earls of Mercia and Northumbria--"'</p> - -<p>'Ugh!' said the Lory, with a shiver.</p> - -<p>'I beg your pardon!' said the Mouse, frowning, but very -politely: 'Did you speak?'</p> - -<p>'Not I!' said the Lory hastily.</p> - -<p>'I thought you did,' said the Mouse. '--I proceed. "Edwin and -Morcar, the earls of Mercia and Northumbria, declared for him: -and even Stigand, the patriotic archbishop of Canterbury, found -it advisable--"'</p> - -<p>'Found <i>what</i>?' said the Duck.</p> - -<p>'Found <i>it</i>,' the Mouse replied rather crossly: 'of -course you know what "it" means.'</p> - -<p>'I know what "it" means well enough, when <i>I</i> find a -thing,' said the Duck: 'it's generally a frog or a worm. The -question is, what did the archbishop find?'</p> - -<p>The Mouse did not notice this question, but hurriedly went on, -'"--found it advisable to go with Edgar Atheling to meet William -and offer him the crown. William's conduct at first was moderate. -But the insolence of his Normans--" How are you getting on now, -my dear?' it continued, turning to Alice as it spoke.</p> - -<p>'As wet as ever,' said Alice in a melancholy tone: 'it doesn't -seem to dry me at all.'</p> - -<p>'In that case,' said the Dodo solemnly, rising to its feet, 'I -move that the meeting adjourn, for the immediate adoption of more -energetic remedies--'</p> - -<p>'Speak English!' said the Eaglet. 'I don't know the meaning of -half those long words, and, what's more, I don't believe you do -either!' And the Eaglet bent down its head to hide a smile: some -of the other birds tittered audibly.</p> - -<p>'What I was going to say,' said the Dodo in an offended tone, -'was, that the best thing to get us dry would be a -Caucus-race.'</p> - -<p>'What <i>is</i> a Caucus-race?' said Alice; not that she -wanted much to know, but the Dodo had paused as if it thought -that <i>somebody</i> ought to speak, and no one else seemed -inclined to say anything.</p> - -<p>'Why,' said the Dodo, 'the best way to explain it is to do -it.' (And, as you might like to try the thing yourself, some -winter day, I will tell you how the Dodo managed it.)</p> - -<p>First it marked out a race-course, in a sort of circle, ('the -exact shape doesn't matter,' it said,) and then all the party -were placed along the course, here and there. There was no 'One, -two, three, and away,' but they began running when they liked, -and left off when they liked, so that it was not easy to know -when the race was over. However, when they had been running half -an hour or so, and were quite dry again, the Dodo suddenly called -out 'The race is over!' and they all crowded round it, panting, -and asking, 'But who has won?'</p> - -<p>This question the Dodo could not answer without a great deal -of thought, and it sat for a long time with one finger pressed -upon its forehead (the position in which you usually see -Shakespeare, in the pictures of him), while the rest waited in -silence. At last the Dodo said, '<i>everybody</i> has won, and -<i>all</i> must have prizes.'</p> - -<p>'But who is to give the prizes?' quite a chorus of voices -asked.</p> - -<p>'Why, <i>she</i>, of course,' said the Dodo, pointing to Alice -with one finger; and the whole party at once crowded round her, -calling out in a confused way, 'Prizes! Prizes!'</p> - -<p>Alice had no idea what to do, and in despair she put her hand -in her pocket, and pulled out a box of comfits, (luckily the salt -water had not got into it), and handed them round as prizes. -There was exactly one a-piece all round.</p> - -<p>'But she must have a prize herself, you know,' said the -Mouse.</p> - -<p>'Of course,' the Dodo replied very gravely. 'What else have -you got in your pocket?' he went on, turning to Alice.</p> - -<p>'Only a thimble,' said Alice sadly.</p> - -<p>'Hand it over here,' said the Dodo.</p> - -<p>Then they all crowded round her once more, while the Dodo -solemnly presented the thimble, saying 'We beg your acceptance of -this elegant thimble'; and, when it had finished this short -speech, they all cheered.</p> - -<p>Alice thought the whole thing very absurd, but they all looked -so grave that she did not dare to laugh; and, as she could not -think of anything to say, she simply bowed, and took the thimble, -looking as solemn as she could.</p> - -<p>The next thing was to eat the comfits: this caused some noise -and confusion, as the large birds complained that they could not -taste theirs, and the small ones choked and had to be patted on -the back. However, it was over at last, and they sat down again -in a ring, and begged the Mouse to tell them something more.</p> - -<p>'You promised to tell me your history, you know,' said Alice, -'and why it is you hate--C and D,' she added in a whisper, half -afraid that it would be offended again.</p> - -<p>'Mine is a long and a sad tale!' said the Mouse, turning to -Alice, and sighing.</p> - -<p>'It <i>is</i> a long tail, certainly,' said Alice, looking down with -wonder at the Mouse's tail; 'but why do you call it sad?' And she -kept on puzzling about it while the Mouse was speaking, so that -her idea of the tale was something like this:--</p> - -<p>'Fury said to a mouse, That he met in the house, "Let us both -go to law: I will prosecute <i>you</i>. --Come, I'll take no -denial; We must have a trial: For really this morning I've -nothing to do." Said the mouse to the cur, "Such a trial, dear -Sir, With no jury or judge, would be wasting our breath." "I'll be -judge, I'll be jury," said cunning old Fury: "I'll try the whole -cause, and condemn you to death."'</p> - -<p>'You are not attending!' said the Mouse to Alice severely. -'What are you thinking of?'</p> - -<p>'I beg your pardon,' said Alice very humbly: 'you had got to -the fifth bend, I think?'</p> - -<p>'I had <i>not</i>!' cried the Mouse, sharply and very -angrily.</p> - -<p>'A knot!' said Alice, always ready to make herself useful, and -looking anxiously about her. 'Oh, do let me help to undo it!'</p> - -<p>'I shall do nothing of the sort,' said the Mouse, getting up -and walking away. 'You insult me by talking such nonsense!'</p> - -<p>'I didn't mean it!' pleaded poor Alice. 'But you're so easily -offended, you know!'</p> - -<p>The Mouse only growled in reply.</p> - -<p>'Please come back and finish your story!' Alice called after -it; and the others all joined in chorus, 'Yes, please do!' but -the Mouse only shook its head impatiently, and walked a little -quicker.</p> - -<p>'What a pity it wouldn't stay!' sighed the Lory, as soon as it -was quite out of sight; and an old Crab took the opportunity of -saying to her daughter 'Ah, my dear! Let this be a lesson to you -never to lose <i>your</i> temper!' 'Hold your tongue, Ma!' said -the young Crab, a little snappishly. 'You're enough to try the -patience of an oyster!'</p> - -<p>'I wish I had our Dinah here, I know I do!' said Alice aloud, -addressing nobody in particular. 'She'd soon fetch it back!'</p> - -<p>'And who is Dinah, if I might venture to ask the question?' -said the Lory.</p> - -<p>Alice replied eagerly, for she was always ready to talk about -her pet: 'Dinah's our cat. And she's such a capital one for -catching mice you can't think! And oh, I wish you could see her -after the birds! Why, she'll eat a little bird as soon as look at -it!'</p> - -<p>This speech caused a remarkable sensation among the party. -Some of the birds hurried off at once: one old Magpie began -wrapping itself up very carefully, remarking, 'I really must be -getting home; the night-air doesn't suit my throat!' and a Canary -called out in a trembling voice to its children, 'Come away, my -dears! It's high time you were all in bed!' On various pretexts -they all moved off, and Alice was soon left alone.</p> - -<p>'I wish I hadn't mentioned Dinah!' she said to herself in a -melancholy tone. 'Nobody seems to like her, down here, and I'm -sure she's the best cat in the world! Oh, my dear Dinah! I wonder -if I shall ever see you any more!' And here poor Alice began to -cry again, for she felt very lonely and low-spirited. In a little -while, however, she again heard a little pattering of footsteps -in the distance, and she looked up eagerly, half hoping that the -Mouse had changed his mind, and was coming back to finish his -story.</p> - -<hr> -<h3 align="Center">CHAPTER IV</h3> - -<h3 align="Center">The Rabbit Sends in a Little Bill</h3> - -<p>It was the White Rabbit, trotting slowly back again, and -looking anxiously about as it went, as if it had lost something; -and she heard it muttering to itself 'The Duchess! The Duchess! -Oh my dear paws! Oh my fur and whiskers! She'll get me executed, -as sure as ferrets are ferrets! Where <i>can</i> I have dropped -them, I wonder?' Alice guessed in a moment that it was looking -for the fan and the pair of white kid gloves, and she very -good-naturedly began hunting about for them, but they were -nowhere to be seen--everything seemed to have changed since her -swim in the pool, and the great hall, with the glass table and -the little door, had vanished completely.</p> - -<p>Very soon the Rabbit noticed Alice, as she went hunting about, -and called out to her in an angry tone, 'Why, Mary Ann, what -<i>are</i> you doing out here? Run home this moment, and fetch me -a pair of gloves and a fan! Quick, now!' And Alice was so much -frightened that she ran off at once in the direction it pointed -to, without trying to explain the mistake it had made.</p> - -<p>'He took me for his housemaid,' she said to herself as she -ran. 'How surprised he'll be when he finds out who I am! But I'd -better take him his fan and gloves--that is, if I can find them.' -As she said this, she came upon a neat little house, on the door -of which was a bright brass plate with the name 'W. RABBIT' -engraved upon it. She went in without knocking, and hurried -upstairs, in great fear lest she should meet the real Mary Ann, -and be turned out of the house before she had found the fan and -gloves.</p> - -<p>'How queer it seems,' Alice said to herself, 'to be going -messages for a rabbit! I suppose Dinah'll be sending me on -messages next!' And she began fancying the sort of thing that -would happen: '"Miss Alice! Come here directly, and get ready for -your walk!" "Coming in a minute, nurse! But I've got to see that -the mouse doesn't get out." Only I don't think,' Alice went on, -'that they'd let Dinah stop in the house if it began ordering -people about like that!'</p> - -<p>By this time she had found her way into a tidy little room -with a table in the window, and on it (as she had hoped) a fan -and two or three pairs of tiny white kid gloves: she took up the -fan and a pair of the gloves, and was just going to leave the -room, when her eye fell upon a little bottle that stood near the -looking- glass. There was no label this time with the words -'DRINK ME,' but nevertheless she uncorked it and put it to her -lips. 'I know <i>something</i> interesting is sure to happen,' -she said to herself, 'whenever I eat or drink anything; so I'll -just see what this bottle does. I do hope it'll make me grow -large again, for really I'm quite tired of being such a tiny -little thing!'</p> - -<p>It did so indeed, and much sooner than she had expected: -before she had drunk half the bottle, she found her head pressing -against the ceiling, and had to stoop to save her neck from being -broken. She hastily put down the bottle, saying to herself -'That's quite enough--I hope I shan't grow any more--As it is, I -can't get out at the door--I do wish I hadn't drunk quite so -much!'</p> - -<p>Alas! it was too late to wish that! She went on growing, and -growing, and very soon had to kneel down on the floor: in another -minute there was not even room for this, and she tried the effect -of lying down with one elbow against the door, and the other arm -curled round her head. Still she went on growing, and, as a last -resource, she put one arm out of the window, and one foot up the -chimney, and said to herself 'Now I can do no more, whatever -happens. What <i>will</i> become of me?'</p> - -<p>Luckily for Alice, the little magic bottle had now had its -full effect, and she grew no larger: still it was very -uncomfortable, and, as there seemed to be no sort of chance of -her ever getting out of the room again, no wonder she felt -unhappy.</p> - -<p>'It was much pleasanter at home,' thought poor Alice, 'when -one wasn't always growing larger and smaller, and being ordered -about by mice and rabbits. I almost wish I hadn't gone down that -rabbit-hole--and yet--and yet--it's rather curious, you know, -this sort of life! I do wonder what <i>can</i> have happened to -me! When I used to read fairy-tales, I fancied that kind of thing -never happened, and now here I am in the middle of one! There -ought to be a book written about me, that there ought! And when I -grow up, I'll write one--but I'm grown up now,' she added in a -sorrowful tone; 'at least there's no room to grow up any more -<i>here</i>.'</p> - -<p>'But then,' thought Alice, 'shall I <i>never</i> get any older -than I am now? That'll be a comfort, one way--never to be an old -woman-- but then--always to have lessons to learn! Oh, I -shouldn't like <i>that</i>!'</p> - -<p>'Oh, you foolish Alice!' she answered herself. 'How can you -learn lessons in here? Why, there's hardly room for you, and no -room at all for any lesson-books!'</p> - -<p>And so she went on, taking first one side and then the other, -and making quite a conversation of it altogether; but after a few -minutes she heard a voice outside, and stopped to listen.</p> - -<p>'Mary Ann! Mary Ann!' said the voice. 'Fetch me my gloves this -moment!' Then came a little pattering of feet on the stairs. -Alice knew it was the Rabbit coming to look for her, and she -trembled till she shook the house, quite forgetting that she was -now about a thousand times as large as the Rabbit, and had no -reason to be afraid of it.</p> - -<p>Presently the Rabbit came up to the door, and tried to open -it; but, as the door opened inwards, and Alice's elbow was -pressed hard against it, that attempt proved a failure. Alice -heard it say to itself 'Then I'll go round and get in at the -window.'</p> - -<p>'<i>That</i> you won't' thought Alice, and, after waiting till -she fancied she heard the Rabbit just under the window, she -suddenly spread out her hand, and made a snatch in the air. She -did not get hold of anything, but she heard a little shriek and a -fall, and a crash of broken glass, from which she concluded that -it was just possible it had fallen into a cucumber-frame, or -something of the sort.</p> - -<p>Next came an angry voice--the Rabbit's--'Pat! Pat! Where are -you?' And then a voice she had never heard before, 'Sure then I'm -here! Digging for apples, yer honour!'</p> - -<p>'Digging for apples, indeed!' said the Rabbit angrily. 'Here! -Come and help me out of <i>this</i>!' (Sounds of more broken -glass.)</p> - -<p>'Now tell me, Pat, what's that in the window?'</p> - -<p>'Sure, it's an arm, yer honour!' (He pronounced it -'arrum.')</p> - -<p>'An arm, you goose! Who ever saw one that size? Why, it fills -the whole window!'</p> - -<p>'Sure, it does, yer honour: but it's an arm for all that.'</p> - -<p>'Well, it's got no business there, at any rate: go and take it -away!'</p> - -<p>There was a long silence after this, and Alice could only hear -whispers now and then; such as, 'Sure, I don't like it, yer -honour, at all, at all!' 'Do as I tell you, you coward!' and at -last she spread out her hand again, and made another snatch in -the air. This time there were <i>two</i> little shrieks, and more -sounds of broken glass. 'What a number of cucumber-frames there -must be!' thought Alice. 'I wonder what they'll do next! As for -pulling me out of the window, I only wish they <i>could</i>! I'm -sure I don't want to stay in here any longer!'</p> - -<p>She waited for some time without hearing anything more: at -last came a rumbling of little cartwheels, and the sound of a -good many voices all talking together: she made out the words: -'Where's the other ladder?--Why, I hadn't to bring but one; -Bill's got the other--Bill! fetch it here, lad!--Here, put 'em up -at this corner--No, tie 'em together first--they don't reach half -high enough yet--Oh! they'll do well enough; don't be -particular-- Here, Bill! catch hold of this rope--Will the roof -bear?--Mind that loose slate--Oh, it's coming down! Heads below!' -(a loud crash)--'Now, who did that?--It was Bill, I fancy--Who's -to go down the chimney?--Nay, I shan't! <i>you</i> do it!--That I -won't, then!--Bill's to go down--Here, Bill! the master says -you're to go down the chimney!'</p> - -<p>'Oh! So Bill's got to come down the chimney, has he?' said -Alice to herself. 'Shy, they seem to put everything upon Bill! I -wouldn't be in Bill's place for a good deal: this fireplace is -narrow, to be sure; but I <i>think</i> I can kick a little!'</p> - -<p>She drew her foot as far down the chimney as she could, and -waited till she heard a little animal (she couldn't guess of what -sort it was) scratching and scrambling about in the chimney close -above her: then, saying to herself 'This is Bill,' she gave one -sharp kick, and waited to see what would happen next.</p> - -<p>The first thing she heard was a general chorus of 'There goes -Bill!' then the Rabbit's voice along--'Catch him, you by the -hedge!' then silence, and then another confusion of voices--'Hold -up his head--Brandy now--Don't choke him--How was it, old fellow? -What happened to you? Tell us all about it!'</p> - -<p>Last came a little feeble, squeaking voice, ('That's Bill,' -thought Alice,) 'Well, I hardly know--No more, thank ye; I'm -better now--but I'm a deal too flustered to tell you--all I know -is, something comes at me like a Jack-in-the-box, and up I goes -like a sky-rocket!'</p> - -<p>'So you did, old fellow!' said the others.</p> - -<p>'We must burn the house down!' said the Rabbit's voice; and -Alice called out as loud as she could, 'If you do. I'll set Dinah -at you!'</p> - -<p>There was a dead silence instantly, and Alice thought to -herself, 'I wonder what they <i>will</i> do next! If they had any -sense, they'd take the roof off.' After a minute or two, they -began moving about again, and Alice heard the Rabbit say, 'A -barrowful will do, to begin with.'</p> - -<p>'A barrowful of <i>what</i>?' thought Alice; but she had not -long to doubt, for the next moment a shower of little pebbles -came rattling in at the window, and some of them hit her in the -face. 'I'll put a stop to this,' she said to herself, and shouted -out, 'You'd better not do that again!' which produced another -dead silence.</p> - -<p>Alice noticed with some surprise that the pebbles were all -turning into little cakes as they lay on the floor, and a bright -idea came into her head. 'If I eat one of these cakes,' she -thought, 'it's sure to make <i>some</i> change in my size; and as -it can't possibly make me larger, it must make me smaller, I -suppose.'</p> - -<p>So she swallowed one of the cakes, and was delighted to find -that she began shrinking directly. As soon as she was small -enough to get through the door, she ran out of the house, and -found quite a crowd of little animals and birds waiting outside. -The poor little Lizard, Bill, was in the middle, being held up by -two guinea-pigs, who were giving it something out of a bottle. -They all made a rush at Alice the moment she appeared; but she -ran off as hard as she could, and soon found herself safe in a -thick wood.</p> - -<p>'The first thing I've got to do,' said Alice to herself, as -she wandered about in the wood, 'is to grow to my right size -again; and the second thing is to find my way into that lovely -garden. I think that will be the best plan.'</p> - -<p>It sounded an excellent plan, no doubt, and very neatly and -simply arranged; the only difficulty was, that she had not the -smallest idea how to set about it; and while she was peering -about anxiously among the trees, a little sharp bark just over -her head made her look up in a great hurry.</p> - -<p>An enormous puppy was looking down at her with large round -eyes, and feebly stretching out one paw, trying to touch her. -'Poor little thing!' said Alice, in a coaxing tone, and she tried -hard to whistle to it; but she was terribly frightened all the -time at the thought that it might be hungry, in which case it -would be very likely to eat her up in spite of all her -coaxing.</p> - -<p>Hardly knowing what she did, she picked up a little bit of -stick, and held it out to the puppy; whereupon the puppy jumped -into the air off all its feet at once, with a yelp of delight, -and rushed at the stick, and made believe to worry it; then Alice -dodged behind a great thistle, to keep herself from being run -over; and the moment she appeared on the other side, the puppy -made another rush at the stick, and tumbled head over heels in -its hurry to get hold of it; then Alice, thinking it was very -like having a game of play with a cart-horse, and expecting every -moment to be trampled under its feet, ran round the thistle -again; then the puppy began a series of short charges at the -stick, running a very little way forwards each time and a long -way back, and barking hoarsely all the while, till at last it sat -down a good way off, panting, with its tongue hanging out of its -mouth, and its great eyes half shut.</p> - -<p>This seemed to Alice a good opportunity for making her escape; -so she set off at once, and ran till she was quite tired and out -of breath, and till the puppy's bark sounded quite faint in the -distance.</p> - -<p>'And yet what a dear little puppy it was!' said Alice, as she -leant against a buttercup to rest herself, and fanned herself -with one of the leaves: 'I should have liked teaching it tricks -very much, if--if I'd only been the right size to do it! Oh dear! -I'd nearly forgotten that I've got to grow up again! Let me -see--how <i>is</i> it to be managed? I suppose I ought to eat or drink -something or other; but the great question is, what?'</p> - -<p>The great question certainly was, what? Alice looked all round -her at the flowers and the blades of grass, but she did not see -anything that looked like the right thing to eat or drink under -the circumstances. There was a large mushroom growing near her, -about the same height as herself; and when she had looked under -it, and on both sides of it, and behind it, it occurred to her -that she might as well look and see what was on the top of -it.</p> - -<p>She stretched herself up on tiptoe, and peeped over the edge -of the mushroom, and her eyes immediately met those of a large -caterpillar, that was sitting on the top with its arms folded, -quietly smoking a long hookah, and taking not the smallest notice -of her or of anything else.</p> - -<hr> -<h3 align="Center">CHAPTER V</h3> - -<h3 align="Center">Advice from a Caterpillar</h3> - -<p>The Caterpillar and Alice looked at each other for some time -in silence: at last the Caterpillar took the hookah out of its -mouth, and addressed her in a languid, sleepy voice.</p> - -<p>'Who are <i>you</i>?' said the Caterpillar.</p> - -<p>This was not an encouraging opening for a conversation. Alice -replied, rather shyly, 'I--I hardly know, sir, just at present-- -at least I know who I <i>was</i> when I got up this morning, but I think -I must have been changed several times since then.'</p> - -<p>'What do you mean by that?' said the Caterpillar sternly. -'Explain yourself!'</p> - -<p>'I can't explain <i>myself</i>, I'm afraid, sir' said Alice, -'because I'm not myself, you see.'</p> - -<p>'I don't see,' said the Caterpillar.</p> - -<p>'I'm afraid I can't put it more clearly,' Alice replied very -politely, 'for I can't understand it myself to begin with; and -being so many different sizes in a day is very confusing.'</p> - -<p>'It isn't,' said the Caterpillar.</p> - -<p>'Well, perhaps you haven't found it so yet,' said Alice; 'but -when you have to turn into a chrysalis--you will some day, you -know--and then after that into a butterfly, I should think you'll -feel it a little queer, won't you?'</p> - -<p>'Not a bit,' said the Caterpillar.</p> - -<p>'Well, perhaps your feelings may be different,' said Alice; -'all I know is, it would feel very queer to <i>me</i>.'</p> - -<p>'You!' said the Caterpillar contemptuously. 'Who are -<i>you</i>?'</p> - -<p>Which brought them back again to the beginning of the -conversation. Alice felt a little irritated at the Caterpillar's -making such <i>very</i> short remarks, and she drew herself up -and said, very gravely, 'I think, you ought to tell me who -<i>you</i> are, first.'</p> - -<p>'Why?' said the Caterpillar.</p> - -<p>Here was another puzzling question; and as Alice could not -think of any good reason, and as the Caterpillar seemed to be in -a <i>very</i> unpleasant state of mind, she turned away.</p> - -<p>'Come back!' the Caterpillar called after her. 'I've something -important to say!'</p> - -<p>This sounded promising, certainly: Alice turned and came back -again.</p> - -<p>'Keep your temper,' said the Caterpillar.</p> - -<p>'Is that all?' said Alice, swallowing down her anger as well -as she could.</p> - -<p>'No,' said the Caterpillar.</p> - -<p>Alice thought she might as well wait, as she had nothing else -to do, and perhaps after all it might tell her something worth -hearing. For some minutes it puffed away without speaking, but at -last it unfolded its arms, took the hookah out of its mouth -again, and said, 'So you think you're changed, do you?'</p> - -<p>'I'm afraid I am, sir,' said Alice; 'I can't remember things -as I used--and I don't keep the same size for ten minutes -together!'</p> - -<p>'Can't remember <i>what</i> things?' said the Caterpillar.</p> - -<p>'Well, I've tried to say "<i>How doth the little busy -bee,</i>" but it all came different!' Alice replied in a very -melancholy voice.</p> - -<p>'Repeat, "<i>you are old, Father William,</i>"' said the -Caterpillar.</p> - -<p>Alice folded her hands, and began:--</p> - -<p><i>'You are old, Father William,' the young man said, 'And -your hair has become very white; And yet you incessantly stand on -your head-- Do you think, at your age, it is right?'</i></p> - -<p><i>'In my youth,' Father William replied to his son, 'I feared -it might injure the brain; But, now that I'm perfectly sure I -have none, Why, I do it again and again.'</i></p> - -<p><i>'You are old,' said the youth, 'as I mentioned before, And -have grown most uncommonly fat; Yet you turned a back-somersault -in at the door-- Pray, what is the reason of that?'</i></p> - -<p><i>'In my youth,' said the sage, as he shook his grey locks, -'I kept all my limbs very supple By the use of this ointment--one -shilling the box-- Allow me to sell you a couple?'</i></p> - -<p><i>'You are old,' said the youth, 'and your jaws are too weak -For anything tougher than suet; Yet you finished the goose, with -the bones and the beak-- Pray how did you manage to do -it?'</i></p> - -<p><i>'In my youth,' said his father, 'I took to the law, And -argued each case with my wife; And the muscular strength, which -it gave to my jaw, Has lasted the rest of my life.'</i></p> - -<p><i>'You are old,' said the youth, 'one would hardly suppose -That your eye was as steady as ever; Yet you balanced an eel on -the end of your nose-- What made you so awfully clever?'</i></p> - -<p><i>'I have answered three questions, and that is enough,' Said -his father; 'don't give yourself airs! Do you think I can listen -all day to such stuff? Be off, or I'll kick you down -stairs!'</i></p> - -<p>'That is not said right,' said the Caterpillar.</p> - -<p>'Not <i>quite</i> right, I'm afraid,' said Alice, timidly; -'some of the words have got altered.'</p> - -<p>'It is wrong from beginning to end,' said the Caterpillar -decidedly, and there was silence for some minutes.</p> - -<p>The Caterpillar was the first to speak.</p> - -<p>'What size do you want to be?' it asked.</p> - -<p>'Oh, I'm not particular as to size,' Alice hastily replied; -'only one doesn't like changing so often, you know.'</p> - -<p>'I <i>don't</i> know,' said the Caterpillar.</p> - -<p>Alice said nothing: she had never been so much contradicted in -her life before, and she felt that she was losing her temper.</p> - -<p>'Are you content now?' said the Caterpillar.</p> - -<p>'Well, I should like to be a <i>little</i> larger, sir, if you -wouldn't mind,' said Alice: 'three inches is such a wretched -height to be.'</p> - -<p>'It is a very good height indeed!' said the Caterpillar -angrily, rearing itself upright as it spoke (it was exactly three -inches high).</p> - -<p>'But I'm not used to it!' pleaded poor Alice in a piteous -tone. And she thought of herself, 'I wish the creatures wouldn't -be so easily offended!'</p> - -<p>'You'll get used to it in time,' said the Caterpillar; and it -put the hookah into its mouth and began smoking again.</p> - -<p>This time Alice waited patiently until it chose to speak -again. In a minute or two the Caterpillar took the hookah out of -its mouth and yawned once or twice, and shook itself. Then it got -down off the mushroom, and crawled away in the grass, merely -remarking as it went, 'One side will make you grow taller, and -the other side will make you grow shorter.'</p> - -<p>'One side of <i>what</i>? The other side of <i>what</i>?' -thought Alice to herself.</p> - -<p>'Of the mushroom,' said the Caterpillar, just as if she had -asked it aloud; and in another moment it was out of sight.</p> - -<p>Alice remained looking thoughtfully at the mushroom for a -minute, trying to make out which were the two sides of it; and as -it was perfectly round, she found this a very difficult question. -However, at last she stretched her arms round it as far as they -would go, and broke off a bit of the edge with each hand.</p> - -<p>'And now which is which?' she said to herself, and nibbled a -little of the right-hand bit to try the effect: the next moment -she felt a violent blow underneath her chin: it had struck her -foot!</p> - -<p>She was a good deal frightened by this very sudden change, but -she felt that there was no time to be lost, as she was shrinking -rapidly; so she set to work at once to eat some of the other bit. -Her chin was pressed so closely against her foot, that there was -hardly room to open her mouth; but she did it at last, and -managed to swallow a morsel of the lefthand bit.</p> - -<p align="Center">* * * * *</p> - -<p>'Come, my head's free at last!' said Alice in a tone of -delight, which changed into alarm in another moment, when she -found that her shoulders were nowhere to be found: all she could -see, when she looked down, was an immense length of neck, which -seemed to rise like a stalk out of a sea of green leaves that lay -far below her.</p> - -<p>'What <i>can</i> all that green stuff be?' said Alice. 'And -where <i>have</i> my shoulders got to? And oh, my poor hands, how -is it I can't see you?' She was moving them about as she spoke, -but no result seemed to follow, except a little shaking among the -distant green leaves.</p> - -<p>As there seemed to be no chance of getting her hands up to her -head, she tried to get her head down to them, and was delighted -to find that her neck would bend about easily in any direction, -like a serpent. She had just succeeded in curving it down into a -graceful zigzag, and was going to dive in among the leaves, which -she found to be nothing but the tops of the trees under which she -had been wandering, when a sharp hiss made her draw back in a -hurry: a large pigeon had flown into her face, and was beating -her violently with its wings.</p> - -<p>'Serpent!' screamed the Pigeon.</p> - -<p>'I'm <i>not</i> a serpent!' said Alice indignantly. 'Let me -alone!'</p> - -<p>'Serpent, I say again!' repeated the Pigeon, but in a more -subdued tone, and added with a kind of sob, 'I've tried every -way, and nothing seems to suit them!'</p> - -<p>'I haven't the least idea what you're talking about,' said -Alice.</p> - -<p>'I've tried the roots of trees, and I've tried banks, and I've -tried hedges,' the Pigeon went on, without attending to her; 'but -those serpents! There's no pleasing them!'</p> - -<p>Alice was more and more puzzled, but she thought there was no -use in saying anything more till the Pigeon had finished.</p> - -<p>'As if it wasn't trouble enough hatching the eggs,' said the -Pigeon; 'but I must be on the look-out for serpents night and -day! Why, I haven't had a wink of sleep these three weeks!'</p> - -<p>'I'm very sorry you've been annoyed,' said Alice, who was -beginning to see its meaning.</p> - -<p>'And just as I'd taken the highest tree in the wood,' -continued the Pigeon, raising its voice to a shriek, 'and just as -I was thinking I should be free of them at last, they must needs -come wriggling down from the sky! Ugh, Serpent!'</p> - -<p>'But I'm <i>not</i> a serpent, I tell you!' said Alice. 'I'm -a--I'm a--'</p> - -<p>'Well! <i>what</i> are you?' said the Pigeon. 'I can see -you're trying to invent something!'</p> - -<p>'I--I'm a little girl,' said Alice, rather doubtfully, as she -remembered the number of changes she had gone through that -day.</p> - -<p>'A likely story indeed!' said the Pigeon in a tone of the -deepest contempt. 'I've seen a good many little girls in my time, -but never <i>one</i> with such a neck as that! No, no! You're a -serpent; and there's no use denying it. I suppose you'll be -telling me next that you never tasted an egg!'</p> - -<p>'I <i>have</i> tasted eggs, certainly,' said Alice, who was a -very truthful child; 'but little girls eat eggs quite as much as -serpents do, you know.'</p> - -<p>'I don't believe it,' said the Pigeon; 'but if they do, why -then they're a kind of serpent, that's all I can say.'</p> - -<p>This was such a new idea to Alice, that she was quite silent -for a minute or two, which gave the Pigeon the opportunity of -adding, 'You're looking for eggs, I know <i>that</i> well enough; -and what does it matter to me whether you're a little girl or a -serpent?'</p> - -<p>'It matters a good deal to <i>me</i>,' said Alice hastily; -'but I'm not looking for eggs, as it happens; and if I was, I -shouldn't want <i>yours</i>: I don't like them raw.'</p> - -<p>'Well, be off, then!' said the Pigeon in a sulky tone, as it -settled down again into its nest. Alice crouched down among the -trees as well as she could, for her neck kept getting entangled -among the branches, and every now and then she had to stop and -untwist it. After a while she remembered that she still held the -pieces of mushroom in her hands, and she set to work very -carefully, nibbling first at one and then at the other, and -growing sometimes taller and sometimes shorter, until she had -succeeded in bringing herself down to her usual height.</p> - -<p>It was so long since she had been anything near the right -size, that it felt quite strange at first; but she got used to it -in a few minutes, and began talking to herself, as usual. 'Come, -there's half my plan done now! How puzzling all these changes -are! I'm never sure what I'm going to be, from one minute to -another! However, I've got back to my right size: the next thing -is, to get into that beautiful garden--how <i>is</i> that to be -done, I wonder?' As she said this, she came suddenly upon an open -place, with a little house in it about four feet high. 'Whoever -lives there,' thought Alice, 'it'll never do to come upon them -<i>this</i> size: why, I should frighten them out of their wits!' -So she began nibbling at the righthand bit again, and did not -venture to go near the house till she had brought herself down to -nine inches high.</p> - -<hr> -<h3 align="Center">CHAPTER VI</h3> - -<h3 align="Center">Pig and Pepper</h3> - -<p>For a minute or two she stood looking at the house, and -wondering what to do next, when suddenly a footman in livery came -running out of the wood--(she considered him to be a footman -because he was in livery: otherwise, judging by his face only, -she would have called him a fish)--and rapped loudly at the door -with his knuckles. It was opened by another footman in livery, -with a round face, and large eyes like a frog; and both footmen, -Alice noticed, had powdered hair that curled all over their -heads. She felt very curious to know what it was all about, and -crept a little way out of the wood to listen.</p> - -<p>The Fish-Footman began by producing from under his arm a great -letter, nearly as large as himself, and this he handed over to -the other, saying, in a solemn tone, 'For the Duchess. An -invitation from the Queen to play croquet.' The Frog-Footman -repeated, in the same solemn tone, only changing the order of the -words a little, 'From the Queen. An invitation for the Duchess to -play croquet.'</p> - -<p>Then they both bowed low, and their curls got entangled -together.</p> - -<p>Alice laughed so much at this, that she had to run back into -the wood for fear of their hearing her; and when she next peeped -out the Fish-Footman was gone, and the other was sitting on the -ground near the door, staring stupidly up into the sky.</p> - -<p>Alice went timidly up to the door, and knocked.</p> - -<p>'There's no sort of use in knocking,' said the Footman, 'and -that for two reasons. First, because I'm on the same side of the -door as you are; secondly, because they're making such a noise -inside, no one could possibly hear you.' And certainly there was -a most extraordinary noise going on within--a constant howling -and sneezing, and every now and then a great crash, as if a dish -or kettle had been broken to pieces.</p> - -<p>'Please, then,' said Alice, 'how am I to get in?'</p> - -<p>'There might be some sense in your knocking,' the Footman went -on without attending to her, 'if we had the door between us. For -instance, if you were <i>inside</i>, you might knock, and I could -let you out, you know.' He was looking up into the sky all the -time he was speaking, and this Alice thought decidedly uncivil. -'But perhaps he can't help it,' she said to herself; 'his eyes -are so <i>very</i> nearly at the top of his head. But at any rate -he might answer questions.--How am I to get in?' she repeated, -aloud.</p> - -<p>'I shall sit here,' the Footman remarked, 'till -tomorrow--'</p> - -<p>At this moment the door of the house opened, and a large plate -came skimming out, straight at the Footman's head: it just grazed -his nose, and broke to pieces against one of the trees behind -him.</p> - -<p>'--or next day, maybe,' the Footman continued in the same -tone, exactly as if nothing had happened.</p> - -<p>'How am I to get in?' asked Alice again, in a louder tone.</p> - -<p>'<i>Are</i> you to get in at all?' said the Footman. 'That's -the first question, you know.'</p> - -<p>It was, no doubt: only Alice did not like to be told so. 'It's -really dreadful,' she muttered to herself, 'the way all the -creatures argue. It's enough to drive one crazy!'</p> - -<p>The Footman seemed to think this a good opportunity for -repeating his remark, with variations. 'I shall sit here,' he -said, 'on and off, for days and days.'</p> - -<p>'But what am I to do?' said Alice.</p> - -<p>'Anything you like,' said the Footman, and began -whistling.</p> - -<p>'Oh, there's no use in talking to him,' said Alice -desperately: 'he's perfectly idiotic!' And she opened the door -and went in.</p> - -<p>The door led right into a large kitchen, which was full of -smoke from one end to the other: the Duchess was sitting on a -three-legged stool in the middle, nursing a baby; the cook was -leaning over the fire, stirring a large cauldron which seemed to -be full of soup.</p> - -<p>'There's certainly too much pepper in that soup!' Alice said -to herself, as well as she could for sneezing.</p> - -<p>There was certainly too much of it in the air. Even the -Duchess sneezed occasionally; and as for the baby, it was -sneezing and howling alternately without a moment's pause. The -only things in the kitchen that did not sneeze, were the cook, -and a large cat which was sitting on the hearth and grinning from -ear to ear.</p> - -<p>'Please would you tell me,' said Alice, a little timidly, for -she was not quite sure whether it was good manners for her to -speak first, 'why your cat grins like that?'</p> - -<p>'It's a Cheshire cat,' said the Duchess, 'and that's why. -Pig!'</p> - -<p>She said the last word with such sudden violence that Alice -quite jumped; but she saw in another moment that it was addressed -to the baby, and not to her, so she took courage, and went on -again:--</p> - -<p>'I didn't know that Cheshire cats always grinned; in fact, I -didn't know that cats <i>could</i> grin.'</p> - -<p>'They all can,' said the Duchess; 'and most of 'em do.'</p> - -<p>'I don't know of any that do,' Alice said very politely, -feeling quite pleased to have got into a conversation.</p> - -<p>'You don't know much,' said the Duchess; 'and that's a -fact.'</p> - -<p>Alice did not at all like the tone of this remark, and thought -it would be as well to introduce some other subject of -conversation. While she was trying to fix on one, the cook took -the cauldron of soup off the fire, and at once set to work -throwing everything within her reach at the Duchess and the baby ---the fire-irons came first; then followed a shower of saucepans, -plates, and dishes. The Duchess took no notice of them even when -they hit her; and the baby was howling so much already, that it -was quite impossible to say whether the blows hurt it or not.</p> - -<p>'Oh, <i>please</i> mind what you're doing!' cried Alice, -jumping up and down in an agony of terror. 'Oh, there goes his -<i>precious</i> nose'; as an unusually large saucepan flew close -by it, and very nearly carried it off.</p> - -<p>'If everybody minded their own business,' the Duchess said in -a hoarse growl, 'the world would go round a deal faster than it -does.'</p> - -<p>'Which would <i>not</i> be an advantage,' said Alice, who felt -very glad to get an opportunity of showing off a little of her -knowledge. 'Just think of what work it would make with the day -and night! You see the earth takes twenty-four hours to turn -round on its axis--'</p> - -<p>'Talking of axes,' said the Duchess, 'chop off her head!'</p> - -<p>Alice glanced rather anxiously at the cook, to see if she -meant to take the hint; but the cook was busily stirring the -soup, and seemed not to be listening, so she went on again: -'Twenty-four hours, I <i>think</i>; or is it twelve? I--'</p> - -<p>'Oh, don't bother <i>me</i>,' said the Duchess; 'I never could abide -figures!' And with that she began nursing her child again, -singing a sort of lullaby to it as she did so, and giving it a -violent shake at the end of every line:</p> - -<p align="Center"><i>'Speak roughly to your little boy,</i></p> - -<p align="Center"><i>And beat him when he sneezes:</i></p> - -<p align="Center"><i>He only does it to annoy,</i></p> - -<p align="Center"><i>Because he knows it teases.'</i></p> - -<p align="Center">CHORUS</p> - -<p>(In which the cook and the baby joined):--</p> - -<p align="Center">'Wow! wow! wow!'</p> - -<p>While the Duchess sang the second verse of the song, she kept -tossing the baby violently up and down, and the poor little thing -howled so, that Alice could hardly hear the words:--</p> - -<p align="Center"><i>'I speak severely to my boy,</i></p> - -<p align="Center"><i>I beat him when he sneezes;</i></p> - -<p align="Center"><i>For he can thoroughly enjoy</i></p> - -<p align="Center"><i>The pepper when he pleases!'</i></p> - -<p align="Center">CHORUS</p> - -<p align="Center">'Wow! wow! wow!'</p> - -<p>'Here! you may nurse it a bit, if you like!' the Duchess said -to Alice, flinging the baby at her as she spoke. 'I must go and -get ready to play croquet with the Queen,' and she hurried out of -the room. The cook threw a frying-pan after her as she went out, -but it just missed her.</p> - -<p>Alice caught the baby with some difficulty, as it was a queer- -shaped little creature, and held out its arms and legs in all -directions, 'just like a star-fish,' thought Alice. The poor -little thing was snorting like a steam-engine when she caught it, -and kept doubling itself up and straightening itself out again, -so that altogether, for the first minute or two, it was as much -as she could do to hold it.</p> - -<p>As soon as she had made out the proper way of nursing it, -(which was to twist it up into a sort of knot, and then keep -tight hold of its right ear and left foot, so as to prevent its -undoing itself,) she carried it out into the open air. '<i>If</i> -I don't take this child away with me,' thought Alice, 'they're -sure to kill it in a day or two: wouldn't it be murder to leave -it behind?' She said the last words out loud, and the little -thing grunted in reply (it had left off sneezing by this time). -'Don't grunt,' said Alice; 'that's not at all a proper way of -expressing yourself.'</p> - -<p>The baby grunted again, and Alice looked very anxiously into -its face to see what was the matter with it. There could be no -doubt that it had a <i>very</i> turn-up nose, much more like a -snout than a real nose; also its eyes were getting extremely -small for a baby: altogether Alice did not like the look of the -thing at all. 'But perhaps it was only sobbing,' she thought, and -looked into its eyes again, to see if there were any tears.</p> - -<p>No, there were no tears. 'If you're going to turn into a pig, -my dear,' said Alice, seriously, 'I'll have nothing more to do -with you. Mind now!' The poor little thing sobbed again (or -grunted, it was impossible to say which), and they went on for -some while in silence.</p> - -<p>Alice was just beginning to think to herself, 'Now, what am I -to do with this creature when I get it home?' when it grunted -again, so violently, that she looked down into its face in some -alarm. This time there could be <i>no</i> mistake about it: it -was neither more nor less than a pig, and she felt that it would -be quite absurd for her to carry it further.</p> - -<p>So she set the little creature down, and felt quite relieved -to see it trot away quietly into the wood. 'If it had grown up,' -she said to herself, 'it would have made a dreadfully ugly child: -but it makes rather a handsome pig, I think.' And she began -thinking over other children she knew, who might do very well as -pigs, and was just saying to herself, 'if one only knew the right -way to change them--' when she was a little startled by seeing -the Cheshire Cat sitting on a bough of a tree a few yards -off.</p> - -<p>The Cat only grinned when it saw Alice. It looked good- -natured, she thought: still it had <i>very</i> long claws and a -great many teeth, so she felt that it ought to be treated with -respect.</p> - -<p>'Cheshire Puss,' she began, rather timidly, as she did not at -all know whether it would like the name: however, it only grinned -a little wider. 'Come, it's pleased so far,' thought Alice, and -she went on. 'Would you tell me, please, which way I ought to go -from here?'</p> - -<p>'That depends a good deal on where you want to get to,' said -the Cat.</p> - -<p>'I don't much care where--' said Alice.</p> - -<p>'Then it doesn't matter which way you go,' said the Cat.</p> - -<p>'--so long as I get <i>somewhere</i>,' Alice added as an -explanation.</p> - -<p>'Oh, you're sure to do that,' said the Cat, 'if you only walk -long enough.'</p> - -<p>Alice felt that this could not be denied, so she tried another -question. 'What sort of people live about here?'</p> - -<p>'In <i>that</i> direction,' the Cat said, waving its right paw -round, 'lives a Hatter: and in <i>that</i> direction,' waving the -other paw, 'lives a March Hare. Visit either you like: they're -both mad.'</p> - -<p>'But I don't want to go among mad people,' Alice remarked.</p> - -<p>'Oh, you can't help that,' said the Cat: 'we're all mad here. -I'm mad. You're mad.'</p> - -<p>'How do you know I'm mad?' said Alice.</p> - -<p>'You must be,' said the Cat, 'or you wouldn't have come -here.'</p> - -<p>Alice didn't think that proved it at all; however, she went on -'And how do you know that you're mad?'</p> - -<p>'To begin with,' said the Cat, 'a dog's not mad. You grant -that?'</p> - -<p>'I suppose so,' said Alice.</p> - -<p>'Well, then,' the Cat went on, 'you see, a dog growls when -it's angry, and wags its tail when it's pleased. Now I growl when -I'm pleased, and wag my tail when I'm angry. Therefore I'm -mad.'</p> - -<p>'I call it purring, not growling,' said Alice.</p> - -<p>'Call it what you like,' said the Cat. 'Do you play croquet -with the Queen to-day?'</p> - -<p>'I should like it very much,' said Alice, 'but I haven't been -invited yet.'</p> - -<p>'You'll see me there,' said the Cat, and vanished.</p> - -<p>Alice was not much surprised at this, she was getting so used -to queer things happening. While she was looking at the place -where it had been, it suddenly appeared again.</p> - -<p>'By-the-bye, what became of the baby?' said the Cat. 'I'd -nearly forgotten to ask.'</p> - -<p>'It turned into a pig,' Alice quietly said, just as if it had -come back in a natural way.</p> - -<p>'I thought it would,' said the Cat, and vanished again.</p> - -<p>Alice waited a little, half expecting to see it again, but it -did not appear, and after a minute or two she walked on in the -direction in which the March Hare was said to live. 'I've seen -hatters before,' she said to herself; 'the March Hare will be -much the most interesting, and perhaps as this is May it won't be -raving mad--at least not so mad as it was in March.' As she said -this, she looked up, and there was the Cat again, sitting on a -branch of a tree.</p> - -<p>'Did you say pig, or fig?' said the Cat.</p> - -<p>'I said pig,' replied Alice; 'and I wish you wouldn't keep -appearing and vanishing so suddenly: you make one quite -giddy.'</p> - -<p>'All right,' said the Cat; and this time it vanished quite -slowly, beginning with the end of the tail, and ending with the -grin, which remained some time after the rest of it had gone.</p> - -<p>'Well! I've often seen a cat without a grin,' thought Alice; -'but a grin without a cat! It's the most curious thing I ever saw -in my life!'</p> - -<p>She had not gone much farther before she came in sight of the -house of the March Hare: she thought it must be the right house, -because the chimneys were shaped like ears and the roof was -thatched with fur. It was so large a house, that she did not like -to go nearer till she had nibbled some more of the lefthand bit -of mushroom, and raised herself to about two feet high: even then -she walked up towards it rather timidly, saying to herself -'Suppose it should be raving mad after all! I almost wish I'd -gone to see the Hatter instead!'</p> - -<hr> -<h3 align="Center">CHAPTER VII</h3> - -<h3 align="Center">A Mad Tea-Party</h3> - -<p>There was a table set out under a tree in front of the house, -and the March Hare and the Hatter were having tea at it: a -Dormouse was sitting between them, fast asleep, and the other two -were using it as a cushion, resting their elbows on it, and -talking over its head. 'Very uncomfortable for the Dormouse,' -thought Alice; 'only, as it's asleep, I suppose it doesn't -mind.'</p> - -<p>The table was a large one, but the three were all crowded -together at one corner of it: 'No room! No room!' they cried out -when they saw Alice coming. 'There's <i>plenty</i> of room!' said -Alice indignantly, and she sat down in a large arm-chair at one -end of the table.</p> - -<p>'Have some wine,' the March Hare said in an encouraging -tone.</p> - -<p>Alice looked all round the table, but there was nothing on it -but tea. 'I don't see any wine,' she remarked.</p> - -<p>'There isn't any,' said the March Hare.</p> - -<p>'Then it wasn't very civil of you to offer it,' said Alice -angrily.</p> - -<p>'It wasn't very civil of you to sit down without being -invited,' said the March Hare.</p> - -<p>'I didn't know it was <i>your</i> table,' said Alice; 'it's -laid for a great many more than three.'</p> - -<p>'Your hair wants cutting,' said the Hatter. He had been -looking at Alice for some time with great curiosity, and this was -his first speech.</p> - -<p>'You should learn not to make personal remarks,' Alice said -with some severity; 'it's very rude.'</p> - -<p>The Hatter opened his eyes very wide on hearing this; but all -he <i>said</i> was, 'Why is a raven like a writing-desk?'</p> - -<p>'Come, we shall have some fun now!' thought Alice. 'I'm glad -they've begun asking riddles.--I believe I can guess that,' she -added aloud.</p> - -<p>'Do you mean that you think you can find out the answer to -it?' said the March Hare.</p> - -<p>'Exactly so,' said Alice.</p> - -<p>'Then you should say what you mean,' the March Hare went -on.</p> - -<p>'I do,' Alice hastily replied; 'at least--at least I mean what -I say--that's the same thing, you know.'</p> - -<p>'Not the same thing a bit!' said the Hatter. 'You might just -as well say that "I see what I eat" is the same thing as "I eat -what I see"!'</p> - -<p>'You might just as well say,' added the March Hare, 'that "I -like what I get" is the same thing as "I get what I like"!'</p> - -<p>'You might just as well say,' added the Dormouse, who seemed -to be talking in his sleep, 'that "I breathe when I sleep" is the -same thing as "I sleep when I breathe"!'</p> - -<p>'It <i>is</i> the same thing with you,' said the Hatter, and -here the conversation dropped, and the party sat silent for a -minute, while Alice thought over all she could remember about -ravens and writing-desks, which wasn't much.</p> - -<p>The Hatter was the first to break the silence. 'What day of -the month is it?' he said, turning to Alice: he had taken his -watch out of his pocket, and was looking at it uneasily, shaking -it every now and then, and holding it to his ear.</p> - -<p>Alice considered a little, and then said 'The fourth.'</p> - -<p>'Two days wrong!' sighed the Hatter. 'I told you butter -wouldn't suit the works!' he added looking angrily at the March -Hare.</p> - -<p>'It was the <i>best</i> butter,' the March Hare meekly -replied.</p> - -<p>'Yes, but some crumbs must have got in as well,' the Hatter -grumbled: 'you shouldn't have put it in with the -bread-knife.'</p> - -<p>The March Hare took the watch and looked at it gloomily: then -he dipped it into his cup of tea, and looked at it again: but he -could think of nothing better to say than his first remark, 'It -was the <i>best</i> butter, you know.'</p> - -<p>Alice had been looking over his shoulder with some curiosity. -'What a funny watch!' she remarked. 'It tells the day of the -month, and doesn't tell what o'clock it is!'</p> - -<p>'Why should it?' muttered the Hatter. 'Does <i>your</i> watch -tell you what year it is?'</p> - -<p>'Of course not,' Alice replied very readily: 'but that's -because it stays the same year for such a long time -together.'</p> - -<p>'Which is just the case with <i>mine</i>,' said the -Hatter.</p> - -<p>Alice felt dreadfully puzzled. The Hatter's remark seemed to -have no sort of meaning in it, and yet it was certainly English. -'I don't quite understand you,' she said, as politely as she -could.</p> - -<p>'The Dormouse is asleep again,' said the Hatter, and he poured -a little hot tea upon its nose.</p> - -<p>The Dormouse shook its head impatiently, and said, without -opening its eyes, 'Of course, of course; just what I was going to -remark myself.'</p> - -<p>'Have you guessed the riddle yet?' the Hatter said, turning to -Alice again.</p> - -<p>'No, I give it up,' Alice replied: 'what's the answer?'</p> - -<p>'I haven't the slightest idea,' said the Hatter.</p> - -<p>'Nor I,' said the March Hare.</p> - -<p>Alice sighed wearily. 'I think you might do something better -with the time,' she said, 'than waste it in asking riddles that -have no answers.'</p> - -<p>'If you knew Time as well as I do,' said the Hatter, 'you -wouldn't talk about wasting <i>it</i>. It's <i>him</i>.'</p> - -<p>'I don't know what you mean,' said Alice.</p> - -<p>'Of course you don't!' the Hatter said, tossing his head -contemptuously. 'I dare say you never even spoke to Time!'</p> - -<p>'Perhaps not,' Alice cautiously replied: 'but I know I have to -beat time when I learn music.'</p> - -<p>'Ah! that accounts for it,' said the Hatter. 'He won't stand -beating. Now, if you only kept on good terms with him, he'd do -almost anything you liked with the clock. For instance, suppose -it were nine o'clock in the morning, just time to begin lessons: -you'd only have to whisper a hint to Time, and round goes the -clock in a twinkling! Half-past one, time for dinner!'</p> - -<p>('I only wish it was,' the March Hare said to itself in a -whisper.)</p> - -<p>'That would be grand, certainly,' said Alice thoughtfully: -'but then--I shouldn't be hungry for it, you know.'</p> - -<p>'Not at first, perhaps,' said the Hatter: 'but you could keep -it to half-past one as long as you liked.'</p> - -<p>'Is that the way <i>you</i> manage?' Alice asked.</p> - -<p>The Hatter shook his head mournfully. 'Not I!' he replied. 'We -quarrelled last March--just before <i>he</i> went mad, you -know--' (pointing with his tea spoon at the March Hare,) '--it -was at the great concert given by the Queen of Hearts, and I had -to sing</p> - -<p><i>"Twinkle, twinkle, little bat!</i></p> - -<p><i>How I wonder what you're at!"</i></p> - -<p>You know the song, perhaps?'</p> - -<p>'I've heard something like it,' said Alice.</p> - -<p>'It goes on, you know,' the Hatter continued, 'in this -way:--</p> - -<p><i>"Up above the world you fly,</i></p> - -<p><i>Like a tea-tray in the sky.</i></p> - -<p><i>Twinkle, twinkle--"'</i></p> - -<p>Here the Dormouse shook itself, and began singing in its sleep -'<i>Twinkle, twinkle, twinkle, twinkle--</i>' and went on so long -that they had to pinch it to make it stop.</p> - -<p>'Well, I'd hardly finished the first verse,' said the Hatter, -'when the Queen jumped up and bawled out, "He's murdering the -time! Off with his head!"'</p> - -<p>'How dreadfully savage!' exclaimed Alice.</p> - -<p>'And ever since that,' the Hatter went on in a mournful tone, -'he won't do a thing I ask! It's always six o'clock now.'</p> - -<p>A bright idea came into Alice's head. 'Is that the reason so -many tea-things are put out here?' she asked.</p> - -<p>'Yes, that's it,' said the Hatter with a sigh: 'it's always -tea-time, and we've no time to wash the things between -whiles.'</p> - -<p>'Then you keep moving round, I suppose?' said Alice.</p> - -<p>'Exactly so,' said the Hatter: 'as the things get used -up.'</p> - -<p>'But what happens when you come to the beginning again?' Alice -ventured to ask.</p> - -<p>'Suppose we change the subject,' the March Hare interrupted, -yawning. 'I'm getting tired of this. I vote the young lady tells -us a story.'</p> - -<p>'I'm afraid I don't know one,' said Alice, rather alarmed at -the proposal.</p> - -<p>'Then the Dormouse shall!' they both cried. 'Wake up, -Dormouse!' And they pinched it on both sides at once.</p> - -<p>The Dormouse slowly opened his eyes. 'I wasn't asleep,' he -said in a hoarse, feeble voice: 'I heard every word you fellows -were saying.'</p> - -<p>'Tell us a story!' said the March Hare.</p> - -<p>'Yes, please do!' pleaded Alice.</p> - -<p>'And be quick about it,' added the Hatter, 'or you'll be -asleep again before it's done.'</p> - -<p>'Once upon a time there were three little sisters,' the -Dormouse began in a great hurry; 'and their names were Elsie, -Lacie, and Tillie; and they lived at the bottom of a well--'</p> - -<p>'What did they live on?' said Alice, who always took a great -interest in questions of eating and drinking.</p> - -<p>'They lived on treacle,' said the Dormouse, after thinking a -minute or two.</p> - -<p>'They couldn't have done that, you know,' Alice gently -remarked; 'they'd have been ill.'</p> - -<p>'So they were,' said the Dormouse; '<i>very</i> ill.'</p> - -<p>Alice tried to fancy to herself what such an extraordinary -ways of living would be like, but it puzzled her too much, so she -went on: 'But why did they live at the bottom of a well?'</p> - -<p>'Take some more tea,' the March Hare said to Alice, very -earnestly.</p> - -<p>'I've had nothing yet,' Alice replied in an offended tone, 'so -I can't take more.'</p> - -<p>'You mean you can't take <i>less</i>,' said the Hatter: 'it's -very easy to take <i>more</i> than nothing.'</p> - -<p>'Nobody asked <i>your</i> opinion,' said Alice.</p> - -<p>'Who's making personal remarks now?' the Hatter asked -triumphantly.</p> - -<p>Alice did not quite know what to say to this: so she helped -herself to some tea and bread-and-butter, and then turned to the -Dormouse, and repeated her question. 'Why did they live at the -bottom of a well?'</p> - -<p>The Dormouse again took a minute or two to think about it, and -then said, 'It was a treacle-well.'</p> - -<p>'There's no such thing!' Alice was beginning very angrily, but -the Hatter and the March Hare went 'Sh! sh!' and the Dormouse -sulkily remarked, 'If you can't be civil, you'd better finish the -story for yourself.'</p> - -<p>'No, please go on!' Alice said very humbly; 'I won't interrupt -again. I dare say there may be <i>one</i>.'</p> - -<p>'One, indeed!' said the Dormouse indignantly. However, he -consented to go on. 'And so these three little sisters--they were -learning to draw, you know--'</p> - -<p>'What did they draw?' said Alice, quite forgetting her -promise.</p> - -<p>'Treacle,' said the Dormouse, without considering at all this -time.</p> - -<p>'I want a clean cup,' interrupted the Hatter: 'let's all move -one place on.'</p> - -<p>He moved on as he spoke, and the Dormouse followed him: the -March Hare moved into the Dormouse's place, and Alice rather -unwillingly took the place of the March Hare. The Hatter was the -only one who got any advantage from the change: and Alice was a -good deal worse off than before, as the March Hare had just upset -the milk-jug into his plate.</p> - -<p>Alice did not wish to offend the Dormouse again, so she began -very cautiously: 'But I don't understand. Where did they draw the -treacle from?'</p> - -<p>'You can draw water out of a water-well,' said the Hatter; 'so -I should think you could draw treacle out of a treacle-well--eh, -stupid?'</p> - -<p>'But they were <i>in</i> the well,' Alice said to the -Dormouse, not choosing to notice this last remark.</p> - -<p>'Of course they were', said the Dormouse; '--well in.'</p> - -<p>This answer so confused poor Alice, that she let the Dormouse -go on for some time without interrupting it.</p> - -<p>'They were learning to draw,' the Dormouse went on, yawning -and rubbing its eyes, for it was getting very sleepy; 'and they -drew all manner of things--everything that begins with an -M--'</p> - -<p>'Why with an M?' said Alice.</p> - -<p>'Why not?' said the March Hare.</p> - -<p>Alice was silent.</p> - -<p>The Dormouse had closed its eyes by this time, and was going -off into a doze; but, on being pinched by the Hatter, it woke up -again with a little shriek, and went on: '--that begins with an -M, such as mouse-traps, and the moon, and memory, and muchness-- -you know you say things are "much of a muchness"--did you ever -see such a thing as a drawing of a muchness?'</p> - -<p>'Really, now you ask me,' said Alice, very much confused, 'I -don't think--'</p> - -<p>'Then you shouldn't talk,' said the Hatter.</p> - -<p>This piece of rudeness was more than Alice could bear: she got -up in great disgust, and walked off; the Dormouse fell asleep -instantly, and neither of the others took the least notice of her -going, though she looked back once or twice, half hoping that -they would call after her: the last time she saw them, they were -trying to put the Dormouse into the teapot.</p> - -<p>'At any rate I'll never go <i>there</i> again!' said Alice as -she picked her way through the wood. 'It's the stupidest -tea-party I ever was at in all my life!'</p> - -<p>Just as she said this, she noticed that one of the trees had a -door leading right into it. 'That's very curious!' she thought. -'But everything's curious today. I think I may as well go in at -once.' And in she went.</p> - -<p>Once more she found herself in the long hall, and close to the -little glass table. 'Now, I'll manage better this time,' she said -to herself, and began by taking the little golden key, and -unlocking the door that led into the garden. Then she went to -work nibbling at the mushroom (she had kept a piece of it in her -pocket) till she was about a foot high: then she walked down the -little passage: and <i>then</i>--she found herself at last in the -beautiful garden, among the bright flower-beds and the cool -fountains.</p> - -<hr> -<h3 align="Center">CHAPTER VIII</h3> - -<h3 align="Center">The Queen's Croquet-Ground</h3> - -<p>A large rose-tree stood near the entrance of the garden: the -roses growing on it were white, but there were three gardeners at -it, busily painting them red. Alice thought this a very curious -thing, and she went nearer to watch them, and just as she came up -to them she heard one of them say, 'Look out now, Five! Don't go -splashing paint over me like that!'</p> - -<p>'I couldn't help it,' said Five, in a sulky tone; 'Seven -jogged my elbow.'</p> - -<p>On which Seven looked up and said, 'That's right, Five! Always -lay the blame on others!'</p> - -<p><i>You'd</i> better not talk!' said Five. 'I heard the Queen -say only yesterday you deserved to be beheaded!'</p> - -<p>'What for?' said the one who had spoken first.</p> - -<p>'That's none of <i>your</i> business, Two!' said Seven.</p> - -<p>'Yes, it <i>is</i> his business!' said Five, 'and I'll tell -him--it was for bringing the cook tulip-roots instead of -onions.'</p> - -<p>Seven flung down his brush, and had just begun 'Well, of all -the unjust things--' when his eye chanced to fall upon Alice, as -she stood watching them, and he checked himself suddenly: the -others looked round also, and all of them bowed low.</p> - -<p>'Would you tell me,' said Alice, a little timidly, 'why you -are painting those roses?'</p> - -<p>Five and Seven said nothing, but looked at Two. Two began in a -low voice, 'Why the fact is, you see, Miss, this here ought to -have been a <i>red</i> rose-tree, and we put a white one in by -mistake; and if the Queen was to find it out, we should all have -our heads cut off, you know. So you see, Miss, we're doing our -best, afore she comes, to--' At this moment Five, who had been -anxiously looking across the garden, called out 'The Queen! The -Queen!' and the three gardeners instantly threw themselves flat -upon their faces. There was a sound of many footsteps, and Alice -looked round, eager to see the Queen.</p> - -<p>First came ten soldiers carrying clubs; these were all shaped -like the three gardeners, oblong and flat, with their hands and -feet at the corners: next the ten courtiers; these were -ornamented all over with diamonds, and walked two and two, as the -soldiers did. After these came the royal children; there were ten -of them, and the little dears came jumping merrily along hand in -hand, in couples: they were all ornamented with hearts. Next came -the guests, mostly Kings and Queens, and among them Alice -recognised the White Rabbit: it was talking in a hurried nervous -manner, smiling at everything that was said, and went by without -noticing her. Then followed the Knave of Hearts, carrying the -King's crown on a crimson velvet cushion; and, last of all this -grand procession, came THE KING AND QUEEN OF HEARTS.</p> - -<p>Alice was rather doubtful whether she ought not to lie down on -her face like the three gardeners, but she could not remember -ever having heard of such a rule at processions; 'and besides, -what would be the use of a procession,' thought she, 'if people -had all to lie down upon their faces, so that they couldn't see -it?' So she stood still where she was, and waited.</p> - -<p>When the procession came opposite to Alice, they all stopped -and looked at her, and the Queen said severely 'Who is this?' She -said it to the Knave of Hearts, who only bowed and smiled in -reply.</p> - -<p>'Idiot!' said the Queen, tossing her head impatiently; and, -turning to Alice, she went on, 'What's your name, child?'</p> - -<p>'My name is Alice, so please your Majesty,' said Alice very -politely; but she added, to herself, 'Why, they're only a pack of -cards, after all. I needn't be afraid of them!'</p> - -<p>'And who are <i>these</i>?' said the Queen, pointing to the -three gardeners who were lying round the rosetree; for, you see, -as they were lying on their faces, and the pattern on their backs -was the same as the rest of the pack, she could not tell whether -they were gardeners, or soldiers, or courtiers, or three of her -own children.</p> - -<p>'How should I know?' said Alice, surprised at her own courage. -'It's no business of <i>mine</i>.'</p> - -<p>The Queen turned crimson with fury, and, after glaring at her -for a moment like a wild beast, screamed 'Off with her head! -Off--'</p> - -<p>'Nonsense!' said Alice, very loudly and decidedly, and the -Queen was silent.</p> - -<p>The King laid his hand upon her arm, and timidly said -'Consider, my dear: she is only a child!'</p> - -<p>The Queen turned angrily away from him, and said to the Knave -'Turn them over!'</p> - -<p>The Knave did so, very carefully, with one foot.</p> - -<p>'Get up!' said the Queen, in a shrill, loud voice, and the -three gardeners instantly jumped up, and began bowing to the -King, the Queen, the royal children, and everybody else.</p> - -<p>'Leave off that!' screamed the Queen. 'You make me giddy.' And -then, turning to the rose-tree, she went on, 'What <i>have</i> -you been doing here?'</p> - -<p>'May it please your Majesty,' said Two, in a very humble tone, -going down on one knee as he spoke, 'we were trying--'</p> - -<p>'I see!' said the Queen, who had meanwhile been examining the -roses. 'Off with their heads!' and the procession moved on, three -of the soldiers remaining behind to execute the unfortunate -gardeners, who ran to Alice for protection.</p> - -<p>'You shan't be beheaded!' said Alice, and she put them into a -large flower-pot that stood near. The three soldiers wandered -about for a minute or two, looking for them, and then quietly -marched off after the others.</p> - -<p>'Are their heads off?' shouted the Queen.</p> - -<p>'Their heads are gone, if it please your Majesty!' the -soldiers shouted in reply.</p> - -<p>'That's right!' shouted the Queen. 'Can you play croquet?'</p> - -<p>The soldiers were silent, and looked at Alice, as the question -was evidently meant for her.</p> - -<p>'Yes!' shouted Alice.</p> - -<p>'Come on, then!' roared the Queen, and Alice joined the -procession, wondering very much what would happen next.</p> - -<p>'It's--it's a very fine day!' said a timid voice at her side. -She was walking by the White Rabbit, who was peeping anxiously -into her face.</p> - -<p>'Very,' said Alice: '--where's the Duchess?'</p> - -<p>'Hush! Hush!' said the Rabbit in a low, hurried tone. He -looked anxiously over his shoulder as he spoke, and then raised -himself upon tiptoe, put his mouth close to her ear, and -whispered 'She's under sentence of execution.'</p> - -<p>'What for?' said Alice.</p> - -<p>'Did you say "What a pity!"?' the Rabbit asked.</p> - -<p>'No, I didn't,' said Alice: 'I don't think it's at all a pity. -I said "What for?"'</p> - -<p>'She boxed the Queen's ears--' the Rabbit began. Alice gave a -little scream of laughter. 'Oh, hush!' the Rabbit whispered in a -frightened tone. 'The Queen will hear you! You see, she came -rather late, and the Queen said--'</p> - -<p>'Get to your places!' shouted the Queen in a voice of thunder, -and people began running about in all directions, tumbling up -against each other; however, they got settled down in a minute or -two, and the game began. Alice thought she had never seen such a -curious croquet-ground in her life; it was all ridges and -furrows; the balls were live hedgehogs, the mallets live -flamingoes, and the soldiers had to double themselves up and to -stand on their hands and feet, to make the arches.</p> - -<p>The chief difficulty Alice found at first was in managing her -flamingo: she succeeded in getting its body tucked away, -comfortably enough, under her arm, with its legs hanging down, -but generally, just as she had got its neck nicely straightened -out, and was going to give the hedgehog a blow with its head, it -<i>would</i> twist itself round and look up in her face, with -such a puzzled expression that she could not help bursting out -laughing: and when she had got its head down, and was going to -begin again, it was very provoking to find that the hedgehog had -unrolled itself, and was in the act of crawling away: besides all -this, there was generally a ridge or furrow in the way wherever -she wanted to send the hedgehog to, and, as the doubled-up -soldiers were always getting up and walking off to other parts of -the ground, Alice soon came to the conclusion that it was a very -difficult game indeed.</p> - -<p>The players all played at once without waiting for turns, -quarrelling all the while, and fighting for the hedgehogs; and in -a very short time the Queen was in a furious passion, and went -stamping about, and shouting 'Off with his head!' or 'Off with -her head!' about once in a minute.</p> - -<p>Alice began to feel very uneasy: to be sure, she had not as -yet had any dispute with the Queen, but she knew that it might -happen any minute, 'and then,' thought she, 'what would become of -me? They're dreadfully fond of beheading people here; the great -wonder is, that there's any one left alive!'</p> - -<p>She was looking about for some way of escape, and wondering -whether she could get away without being seen, when she noticed a -curious appearance in the air: it puzzled her very much at first, -but, after watching it a minute or two, she made it out to be a -grin, and she said to herself 'It's the Cheshire Cat: now I shall -have somebody to talk to.'</p> - -<p>'How are you getting on?' said the Cat, as soon as there was -mouth enough for it to speak with.</p> - -<p>Alice waited till the eyes appeared, and then nodded. 'It's no -use speaking to it,' she thought, 'till its ears have come, or at -least one of them.' In another minute the whole head appeared, -and then Alice put down her flamingo, and began an account of the -game, feeling very glad she had someone to listen to her. The Cat -seemed to think that there was enough of it now in sight, and no -more of it appeared.</p> - -<p>'I don't think they play at all fairly,' Alice began, in -rather a complaining tone, 'and they all quarrel so dreadfully -one can't hear oneself speak--and they don't seem to have any -rules in particular; at least, if there are, nobody attends to -them--and you've no idea how confusing it is all the things being -alive; for instance, there's the arch I've got to go through next -walking about at the other end of the ground--and I should have -croqueted the Queen's hedgehog just now, only it ran away when it -saw mine coming!'</p> - -<p>'How do you like the Queen?' said the Cat in a low voice.</p> - -<p>'Not at all,' said Alice: 'she's so extremely--' Just then she -noticed that the Queen was close behind her, listening: so she -went on, '--likely to win, that it's hardly worth while finishing -the game.'</p> - -<p>The Queen smiled and passed on.</p> - -<p>'Who <i>are</i> you talking to?' said the King, going up to -Alice, and looking at the Cat's head with great curiosity.</p> - -<p>'It's a friend of mine--a Cheshire Cat,' said Alice: 'allow me -to introduce it.'</p> - -<p>'I don't like the look of it at all,' said the King: 'however, -it may kiss my hand if it likes.'</p> - -<p>'I'd rather not,' the Cat remarked.</p> - -<p>'Don't be impertinent,' said the King, 'and don't look at me -like that!' He got behind Alice as he spoke.</p> - -<p>'A cat may look at a king,' said Alice. 'I've read that in -some book, but I don't remember where.'</p> - -<p>'Well, it must be removed,' said the King very decidedly, and -he called the Queen, who was passing at the moment, 'My dear! I -wish you would have this cat removed!'</p> - -<p>The Queen had only one way of settling all difficulties, great -or small. 'Off with his head!' she said, without even looking -round.</p> - -<p>'I'll fetch the executioner myself,' said the King eagerly, -and he hurried off.</p> - -<p>Alice thought she might as well go back, and see how the game -was going on, as she heard the Queen's voice in the distance, -screaming with passion. She had already heard her sentence three -of the players to be executed for having missed their turns, and -she did not like the look of things at all, as the game was in -such confusion that she never knew whether it was her turn or -not. So she went in search of her hedgehog.</p> - -<p>The hedgehog was engaged in a fight with another hedgehog, -which seemed to Alice an excellent opportunity for croqueting one -of them with the other: the only difficulty was, that her -flamingo was gone across to the other side of the garden, where -Alice could see it trying in a helpless sort of way to fly up -into a tree.</p> - -<p>By the time she had caught the flamingo and brought it back, -the fight was over, and both the hedgehogs were out of sight: -'but it doesn't matter much,' thought Alice, 'as all the arches -are gone from this side of the ground.' So she tucked it away -under her arm, that it might not escape again, and went back for -a little more conversation with her friend.</p> - -<p>When she got back to the Cheshire Cat, she was surprised to -find quite a large crowd collected round it: there was a dispute -going on between the executioner, the King, and the Queen, who -were all talking at once, while all the rest were quite silent, -and looked very uncomfortable.</p> - -<p>The moment Alice appeared, she was appealed to by all three to -settle the question, and they repeated their arguments to her, -though, as they all spoke at once, she found it very hard indeed -to make out exactly what they said.</p> - -<p>The executioner's argument was, that you couldn't cut off a -head unless there was a body to cut it off from: that he had -never had to do such a thing before, and he wasn't going to begin -at <i>his</i> time of life.</p> - -<p>The King's argument was, that anything that had a head could -be beheaded, and that you weren't to talk nonsense.</p> - -<p>The Queen's argument was, that if something wasn't done about -it in less than no time she'd have everybody executed, all round. -(It was this last remark that had made the whole party look so -grave and anxious.)</p> - -<p>Alice could think of nothing else to say but 'It belongs to -the Duchess: you'd better ask <i>her</i> about it.'</p> - -<p>'She's in prison,' the Queen said to the executioner: 'fetch -her here.' And the executioner went off like an arrow.</p> - -<p>The Cat's head began fading away the moment he was gone, and, -by the time he had come back with the Duchess, it had entirely -disappeared; so the King and the executioner ran wildly up and -down looking for it, while the rest of the party went back to the -game.</p> - -<hr> -<h3 align="Center">CHAPTER IX</h3> - -<h3 align="Center">The Mock Turtle's Story</h3> - -<p>'You can't think how glad I am to see you again, you dear old -thing!' said the Duchess, as she tucked her arm affectionately -into Alice's, and they walked off together.</p> - -<p>Alice was very glad to find her in such a pleasant temper, and -thought to herself that perhaps it was only the pepper that had -made her so savage when they met in the kitchen.</p> - -<p>'When <i>I'm</i> a Duchess,' she said to herself, (not in a -very hopeful tone though), 'I won't have any pepper in my kitchen -<i>at all</i>. Soup does very well without--Maybe it's always -pepper that makes people hot-tempered,' she went on, very much -pleased at having found out a new kind of rule, 'and vinegar that -makes them sour--and camomile that makes them bitter--and--and -barley-sugar and such things that make children sweet-tempered. I -only wish people knew that: then they wouldn't be so stingy about -it, you know--'</p> - -<p>She had quite forgotten the Duchess by this time, and was a -little startled when she heard her voice close to her ear. -'You're thinking about something, my dear, and that makes you -forget to talk. I can't tell you just now what the moral of that -is, but I shall remember it in a bit.'</p> - -<p>'Perhaps it hasn't one,' Alice ventured to remark.</p> - -<p>'Tut, tut, child!' said the Duchess. 'Everything's got a -moral, if only you can find it.' And she squeezed herself up -closer to Alice's side as she spoke.</p> - -<p>Alice did not much like keeping so close to her: first, -because the Duchess was <i>very</i> ugly; and secondly, because she was -exactly the right height to rest her chin upon Alice's shoulder, -and it was an uncomfortably sharp chin. However, she did not like -to be rude, so she bore it as well as she could.</p> - -<p>'The game's going on rather better now,' she said, by way of -keeping up the conversation a little.</p> - -<p>''Tis so,' said the Duchess: 'and the moral of that is--"Oh, -'tis love, 'tis love, that makes the world go round!"'</p> - -<p>'Somebody said,' Alice whispered, 'that it's done by everybody -minding their own business!'</p> - -<p>'Ah, well! It means much the same thing,' said the Duchess, -digging her sharp little chin into Alice's shoulder as she added, -'and the moral of <i>that</i> is--"Take care of the sense, and -the sounds will take care of themselves."'</p> - -<p>'How fond she is of finding morals in things!' Alice thought -to herself.</p> - -<p>'I dare say you're wondering why I don't put my arm round your -waist,' the Duchess said after a pause: 'the reason is, that I'm -doubtful about the temper of your flamingo. Shall I try the -experiment?'</p> - -<p>'<i>He</i> might bite,' Alice cautiously replied, not feeling -at all anxious to have the experiment tried.</p> - -<p>'Very true,' said the Duchess: 'flamingoes and mustard both -bite. And the moral of that is--"Birds of a feather flock -together."'</p> - -<p>'Only mustard isn't a bird,' Alice remarked.</p> - -<p>'Right, as usual,' said the Duchess: 'what a clear way you -have of putting things!'</p> - -<p>'It's a mineral, I <i>think</i>,' said Alice.</p> - -<p>'Of course it is,' said the Duchess, who seemed ready to agree -to everything that Alice said; 'there's a large mustard-mine near -here. And the moral of that is--"The more there is of mine, the -less there is of yours."'</p> - -<p>'Oh, I know!' exclaimed Alice, who had not attended to this -last remark, 'it's a vegetable. It doesn't look like one, but it -is.'</p> - -<p>'I quite agree with you,' said the Duchess; 'and the moral of -that is--"Be what you would seem to be"--or if you'd like it put -more simply--"Never imagine yourself not to be otherwise than -what it might appear to others that what you were or might have -been was not otherwise than what you had been would have appeared -to them to be otherwise."'</p> - -<p>'I think I should understand that better,' Alice said very -politely, 'if I had it written down: but I can't quite follow it -as you say it.'</p> - -<p>'That's nothing to what I could say if I chose,' the Duchess -replied, in a pleased tone.</p> - -<p>'Pray don't trouble yourself to say it any longer than that,' -said Alice.</p> - -<p>'Oh, don't talk about trouble!' said the Duchess. 'I make you -a present of everything I've said as yet.'</p> - -<p>'A cheap sort of present!' thought Alice. 'I'm glad they don't -give birthday presents like that!' But she did not venture to say -it out loud.</p> - -<p>'Thinking again?' the Duchess asked, with another dig of her -sharp little chin.</p> - -<p>'I've a right to think,' said Alice sharply, for she was -beginning to feel a little worried.</p> - -<p>'Just about as much right,' said the Duchess, 'as pigs have to -fly; and the m--'</p> - -<p>But here, to Alice's great surprise, the Duchess's voice died -away, even in the middle of her favourite word 'moral,' and the -arm that was linked into hers began to tremble. Alice looked up, -and there stood the Queen in front of them, with her arms folded, -frowning like a thunderstorm.</p> - -<p>'A fine day, your Majesty!' the Duchess began in a low, weak -voice.</p> - -<p>'Now, I give you fair warning,' shouted the Queen, stamping on -the ground as she spoke; 'either you or your head must be off, -and that in about half no time! Take your choice!'</p> - -<p>The Duchess took her choice, and was gone in a moment.</p> - -<p>'Let's go on with the game,' the Queen said to Alice; and -Alice was too much frightened to say a word, but slowly followed -her back to the croquet-ground.</p> - -<p>The other guests had taken advantage of the Queen's absence, -and were resting in the shade: however, the moment they saw her, -they hurried back to the game, the Queen merely remarking that a -moment's delay would cost them their lives.</p> - -<p>All the time they were playing the Queen never left off -quarrelling with the other players, and shouting 'Off with his -head!' or 'Off with her head!' Those whom she sentenced were -taken into custody by the soldiers, who of course had to leave -off being arches to do this, so that by the end of half an hour -or so there were no arches left, and all the players, except the -King, the Queen, and Alice, were in custody and under sentence of -execution.</p> - -<p>Then the Queen left off, quite out of breath, and said to -Alice, 'Have you seen the Mock Turtle yet?'</p> - -<p>'No,' said Alice. 'I don't even know what a Mock Turtle -is.'</p> - -<p>'It's the thing Mock Turtle Soup is made from,' said the -Queen.</p> - -<p>'I never saw one, or heard of one,' said Alice.</p> - -<p>'Come on, then,' said the Queen, 'and he shall tell you his -history,'</p> - -<p>As they walked off together, Alice heard the King say in a low -voice, to the company generally, 'You are all pardoned.' 'Come, -<i>that's</i> a good thing!' she said to herself, for she had -felt quite unhappy at the number of executions the Queen had -ordered.</p> - -<p>They very soon came upon a Gryphon, lying fast asleep in the -sun. (<i>If</i> you don't know what a Gryphon is, look at the picture.) -'Up, lazy thing!' said the Queen, 'and take this young lady to -see the Mock Turtle, and to hear his history. I must go back and -see after some executions I have ordered'; and she walked off, -leaving Alice alone with the Gryphon. Alice did not quite like -the look of the creature, but on the whole she thought it would -be quite as safe to stay with it as to go after that savage -Queen: so she waited.</p> - -<p>The Gryphon sat up and rubbed its eyes: then it watched the -Queen till she was out of sight: then it chuckled. 'What fun!' -said the Gryphon, half to itself, half to Alice.</p> - -<p>'What <i>is</i> the fun?' said Alice.</p> - -<p>'Why, <i>she</i>,' said the Gryphon. 'It's all her fancy, -that: they never executes nobody, you know. Come on!'</p> - -<p>'Everybody says "come on!" here,' thought Alice, as she went -slowly after it: 'I never was so ordered about in all my life, -never!'</p> - -<p>They had not gone far before they saw the Mock Turtle in the -distance, sitting sad and lonely on a little ledge of rock, and, -as they came nearer, Alice could hear him sighing as if his heart -would break. She pitied him deeply. 'What is his sorrow?' she -asked the Gryphon, and the Gryphon answered, very nearly in the -same words as before, 'It's all his fancy, that: he hasn't got no -sorrow, you know. Come on!'</p> - -<p>So they went up to the Mock Turtle, who looked at them with -large eyes full of tears, but said nothing.</p> - -<p>'This here young lady,' said the Gryphon, 'she wants for to -know your history, she do.'</p> - -<p>'I'll tell it her,' said the Mock Turtle in a deep, hollow -tone: 'sit down, both of you, and don't speak a word till I've -finished.'</p> - -<p>So they sat down, and nobody spoke for some minutes. Alice -thought to herself, 'I don't see how he can <i>even</i> finish, -if he doesn't begin.' But she waited patiently.</p> - -<p>'Once,' said the Mock Turtle at last, with a deep sigh, 'I was -a real Turtle.'</p> - -<p>These words were followed by a very long silence, broken only -by an occasional exclamation of 'Hjckrrh!' from the Gryphon, and -the constant heavy sobbing of the Mock Turtle. Alice was very -nearly getting up and saying, 'Thank you, sir, for your -interesting story,' but she could not help thinking there -<i>must</i> be more to come, so she sat still and said -nothing.</p> - -<p>'When we were little,' the Mock Turtle went on at last, more -calmly, though still sobbing a little now and then, 'we went to -school in the sea. The master was an old Turtle--we used to call -him Tortoise--'</p> - -<p>'Why did you call him Tortoise, if he wasn't one?' Alice -asked.</p> - -<p>'We called him Tortoise because he taught us,' said the Mock -Turtle angrily: 'really you are very dull!'</p> - -<p>'You ought to be ashamed of yourself for asking such a simple -question,' added the Gryphon; and then they both sat silent and -looked at poor Alice, who felt ready to sink into the earth. At -last the Gryphon said to the Mock Turtle, 'Drive on, old fellow! -Don't be all day about it!' and he went on in these words:</p> - -<p>'Yes, we went to school in the sea, though you mayn't believe -it--'</p> - -<p>'I never said I didn't!' interrupted Alice.</p> - -<p>'You did,' said the Mock Turtle.</p> - -<p>'Hold your tongue!' added the Gryphon, before Alice could -speak again. The Mock Turtle went on.</p> - -<p>'We had the best of educations--in fact, we went to school -every day--'</p> - -<p>'<i>I've</i> been to a day-school, too,' said Alice; 'you -needn't be so proud as all that.'</p> - -<p>'With extras?' asked the Mock Turtle a little anxiously.</p> - -<p>'Yes,' said Alice, 'we learned French and music.'</p> - -<p>'And washing?' said the Mock Turtle.</p> - -<p>'Certainly not!' said Alice indignantly.</p> - -<p>'Ah! then yours wasn't a really good school,' said the Mock -Turtle in a tone of great relief. 'Now at <i>ours</i> they had at -the end of the bill, "French, music, <i>and -washing</i>--extra."'</p> - -<p>'You couldn't have wanted it much,' said Alice; 'living at the -bottom of the sea.'</p> - -<p>'I couldn't afford to learn it.' said the Mock Turtle with a -sigh. 'I only took the regular course.'</p> - -<p>'What was that?' inquired Alice.</p> - -<p>'Reeling and Writhing, of course, to begin with,' the Mock -Turtle replied; 'and then the different branches of Arithmetic-- -Ambition, Distraction, Uglification, and Derision.'</p> - -<p>'I never heard of "Uglification,"' Alice ventured to say. -'What is it?'</p> - -<p>The Gryphon lifted up both its paws in surprise. 'What! Never -heard of uglifying!' it exclaimed. 'You know what to beautify is, -I suppose?'</p> - -<p>'Yes,' said Alice doubtfully: 'it -means--to--make--anything--prettier.'</p> - -<p>'Well, then,' the Gryphon went on, 'if you don't know what to -uglify is, you <i>are</i> a simpleton.'</p> - -<p>Alice did not feel encouraged to ask any more questions about -it, so she turned to the Mock Turtle, and said 'What else had you -to learn?'</p> - -<p>'Well, there was Mystery,' the Mock Turtle replied, counting -off the subjects on his flappers, '--Mystery, ancient and modern, -with Seaography: then Drawling--the Drawling-master was an old -conger-eel, that used to come once a week: <i>He</i> taught us -Drawling, Stretching, and Fainting in Coils.'</p> - -<p>'What was <i>that</i> like?' said Alice.</p> - -<p>'Well, I can't show it you myself,' the Mock Turtle said: 'I'm -too stiff. And the Gryphon never learnt it.'</p> - -<p>'Hadn't time,' said the Gryphon: 'I went to the Classics -master, though. He was an old crab, <i>he</i> was.'</p> - -<p>'I never went to him,' the Mock Turtle said with a sigh: 'he -taught Laughing and Grief, they used to say.'</p> - -<p>'So he did, so he did,' said the Gryphon, sighing in his turn; -and both creatures hid their faces in their paws.</p> - -<p>'And how many hours a day did you do lessons?' said Alice, in -a hurry to change the subject.</p> - -<p>'Ten hours the first day,' said the Mock Turtle: 'nine the -next, and so on.'</p> - -<p>'What a curious plan!' exclaimed Alice.</p> - -<p>'That's the reason they're called lessons,' the Gryphon -remarked: 'because they lessen from day to day.'</p> - -<p>This was quite a new idea to Alice, and she thought it over a -little before she made her next remark. 'Then the eleventh day -must have been a holiday?'</p> - -<p>'Of course it was,' said the Mock Turtle.</p> - -<p>'And how did you manage on the twelfth?' Alice went on -eagerly.</p> - -<p>'That's enough about lessons,' the Gryphon interrupted in a -very decided tone: 'tell her something about the games now.'</p> - -<hr> -<h3 align="Center">CHAPTER X</h3> - -<h3 align="Center">The Lobster Quadrille</h3> - -<p>The Mock Turtle sighed deeply, and drew the back of one -flapper across his eyes. He looked at Alice, and tried to speak, -but for a minute or two sobs choked his voice. 'Same as if he had -a bone in his throat,' said the Gryphon: and it set to work -shaking him and punching him in the back. At last the Mock Turtle -recovered his voice, and, with tears running down his cheeks, he -went on again:--</p> - -<p>'You may not have lived much under the sea--' ('I haven't,' -said Alice)-- 'and perhaps you were never even introduced to a -lobster--' (Alice began to say 'I once tasted--' but checked -herself hastily, and said 'No, never') '--so you can have no idea -what a delightful thing a Lobster Quadrille is!'</p> - -<p>'No, indeed,' said Alice. 'What sort of a dance is it?'</p> - -<p>'Why,' said the Gryphon, 'you first form into a line along the -sea-shore--'</p> - -<p>'Two lines!' cried the Mock Turtle. 'Seals, turtles, salmon, -and so on; then, when you've cleared all the jelly-fish out of -the way--'</p> - -<p>'<i>That</i> generally takes some time,' interrupted the -Gryphon.</p> - -<p>'--you advance twice--'</p> - -<p>'Each with a lobster as a partner!' cried the Gryphon.</p> - -<p>'Of course,' the Mock Turtle said: 'advance twice, set to -partners--'</p> - -<p>'--change lobsters, and retire in same order,' continued the -Gryphon.</p> - -<p>'Then, you know,' the Mock Turtle went on, 'you throw -the--'</p> - -<p>'The lobsters!' shouted the Gryphon, with a bound into the -air.</p> - -<p>'--as far out to sea as you can--'</p> - -<p>'Swim after them!' screamed the Gryphon.</p> - -<p>'Turn a somersault in the sea!' cried the Mock Turtle, -capering wildly about.</p> - -<p>'Change lobster's again!' yelled the Gryphon at the top of its -voice.</p> - -<p>'Back to land again, and that's all the first figure,' said -the Mock Turtle, suddenly dropping his voice; and the two -creatures, who had been jumping about like mad things all this -time, sat down again very sadly and quietly, and looked at -Alice.</p> - -<p>'It must be a very pretty dance,' said Alice timidly.</p> - -<p>'Would you like to see a little of it?' said the Mock -Turtle.</p> - -<p>'Very much indeed,' said Alice.</p> - -<p>'Come, let's try the first figure!' said the Mock Turtle to -the Gryphon. 'We can do without lobsters, you know. Which shall -sing?'</p> - -<p>'Oh, <i>you</i> sing,' said the Gryphon. 'I've forgotten the -words.'</p> - -<p>So they began solemnly dancing round and round Alice, every -now and then treading on her toes when they passed too close, and -waving their forepaws to mark the time, while the Mock Turtle -sang this, very slowly and sadly:--</p> - -<p><i>'"Will you walk a little faster?" said a whiting to a -snail. "There's a porpoise close behind us, and he's treading on -my tail. See how eagerly the lobsters and the turtles all -advance! They are waiting on the shingle--will you come and join -the dance?</i></p> - -<p><i>Will you, won't you, will you, won't you, will you join the -dance? Will you, won't you, will you, won't you, won't you join -the dance?</i></p> - -<p><i>"You can really have no notion how delightful it will be -When they take us up and throw us, with the lobsters, out to -sea!" But the snail replied "Too far, too far!" and gave a look -askance-- Said he thanked the whiting kindly, but he would not -join the dance. Would not, could not, would not, could not, would -not join the dance. Would not, could not, would not, could not, -could not join the dance.</i></p> - -<p><i>'"What matters it how far we go?" his scaly friend replied. -"There is another shore, you know, upon the other side. The -further off from England the nearer is to France-- Then turn not -pale, beloved snail, but come and join the dance.</i></p> - -<p><i>Will you, won't you, will you, won't you, will you join the -dance? Will you, won't you, will you, won't you, won't you join -the dance?"'</i></p> - -<p>'Thank you, it's a very interesting dance to watch,' said -Alice, feeling very glad that it was over at last: 'and I do so -like that curious song about the whiting!'</p> - -<p>'Oh, as to the whiting,' said the Mock Turtle, 'they--you've -seen them, of course?'</p> - -<p>'Yes,' said Alice, 'I've often seen them at dinn--' she -checked herself hastily.</p> - -<p>'I don't know where Dinn may be,' said the Mock Turtle, 'but -if you've seen them so often, of course you know what they're -like.'</p> - -<p>'I believe so,' Alice replied thoughtfully. 'They have their -tails in their mouths--and they're all over crumbs.'</p> - -<p>'You're wrong about the crumbs,' said the Mock Turtle: 'crumbs -would all wash off in the sea. But they <i>have</i> their tails -in their mouths; and the reason is--' here the Mock Turtle yawned -and shut his eyes.--'Tell her about the reason and all that,' he -said to the Gryphon.</p> - -<p>'The reason is,' said the Gryphon, 'that they <i>would</i> go -with the lobsters to the dance. So they got thrown out to sea. So -they had to fall a long way. So they got their tails fast in -their mouths. So they couldn't get them out again. That's -all.'</p> - -<p>'Thank you,' said Alice, 'it's very interesting. I never knew -so much about a whiting before.'</p> - -<p>'I can tell you more than that, if you like,' said the -Gryphon. 'Do you know why it's called a whiting?'</p> - -<p>'I never thought about it,' said Alice. 'Why?'</p> - -<p><i>'It does the boots and shoes.'</i> the Gryphon replied very -solemnly.</p> - -<p>Alice was thoroughly puzzled. 'Does the boots and shoes!' she -repeated in a wondering tone.</p> - -<p>'Why, what are <i>your</i> shoes done with?' said the Gryphon. -'I mean, what makes them so shiny?'</p> - -<p>Alice looked down at them, and considered a little before she -gave her answer. 'They're done with blacking, I believe.'</p> - -<p>'Boots and shoes under the sea,' the Gryphon went on in a deep -voice, 'are done with a whiting. Now you know.'</p> - -<p>'And what are they made of?' Alice asked in a tone of great -curiosity.</p> - -<p>'Soles and eels, of course,' the Gryphon replied rather -impatiently: 'any shrimp could have told you that.'</p> - -<p>'If I'd been the whiting,' said Alice, whose thoughts were -still running on the song, 'I'd have said to the porpoise, "Keep -back, please: we don't want <i>you</i> with us!"'</p> - -<p>'They were obliged to have him with them,' the Mock Turtle -said: 'no wise fish would go anywhere without a porpoise.'</p> - -<p>'Wouldn't it really?' said Alice in a tone of great -surprise.</p> - -<p>'Of course not,' said the Mock Turtle: 'why, if a fish came to -<i>me</i>, and told me he was going a journey, I should say "With -what porpoise?"'</p> - -<p>'Don't you mean "purpose"?' said Alice.</p> - -<p>'I mean what I say,' the Mock Turtle replied in an offended -tone. And the Gryphon added 'Come, let's hear some of <i>your</i> -adventures.'</p> - -<p>'I could tell you my adventures--beginning from this morning,' -said Alice a little timidly: 'but it's no use going back to -yesterday, because I was a different person then.'</p> - -<p>'Explain all that,' said the Mock Turtle.</p> - -<p>'No, no! The adventures first,' said the Gryphon in an -impatient tone: 'explanations take such a dreadful time.'</p> - -<p>So Alice began telling them her adventures from the time when -she first saw the White Rabbit. She was a little nervous about it -just at first, the two creatures got so close to her, one on each -side, and opened their eyes and mouths so <i>very</i> wide, but -she gained courage as she went on. Her listeners were perfectly -quiet till she got to the part about her repeating <i>'You are -old, Father William,'</i> to the Caterpillar, and the words all -coming different, and then the Mock Turtle drew a long breath, -and said 'That's very curious.'</p> - -<p>'It's all about as curious as it can be,' said the -Gryphon.</p> - -<p>'It all came different!' the Mock Turtle repeated -thoughtfully. 'I should like to hear her try and repeat something -now. Tell her to begin.' He looked at the Gryphon as if he -thought it had some kind of authority over Alice.</p> - -<p>'Stand up and repeat <i>"'Tis the voice of the sluggard,"'</i> -said the Gryphon.</p> - -<p>'How the creatures order one about, and make one repeat -lessons!' thought Alice; 'I might as well be at school at once.' -However, she got up, and began to repeat it, but her head was so -full of the Lobster Quadrille, that she hardly knew what she was -saying, and the words came very queer indeed:--</p> - -<p>''Tis the voice of the Lobster; I heard him declare, "You have -baked me too brown, I must sugar my hair." As a duck with its -eyelids, so he with his nose Trims his belt and his buttons, and -turns out his toes.'</p> - -<p>[later editions continued as follows When the sands are all -dry, he is gay as a lark, And will talk in contemptuous tones of -the Shark, But, when the tide rises and sharks are around, His -voice has a timid and tremulous sound.]</p> - -<p>'That's different from what I used to say when I was a child,' -said the Gryphon.</p> - -<p>'Well, I never heard it before,' said the Mock Turtle; 'but it -sounds uncommon nonsense.'</p> - -<p>Alice said nothing; she had sat down with her face in her -hands, wondering if anything would <i>ever</i> happen in a -natural way again.</p> - -<p>'I should like to have it explained,' said the Mock -Turtle.</p> - -<p>'She can't explain it,' said the Gryphon hastily. 'Go on with -the next verse.'</p> - -<p>'But about his toes?' the Mock Turtle persisted. 'How -<i>could</i> he turn them out with his nose, you know?'</p> - -<p>'It's the first position in dancing.' Alice said; but was -dreadfully puzzled by the whole thing, and longed to change the -subject.</p> - -<p>'Go on with the next verse,' the Gryphon repeated impatiently: -'it begins "I passed by his garden."'</p> - -<p>Alice did not dare to disobey, though she felt sure it would -all come wrong, and she went on in a trembling voice:--</p> - -<p><i>'I passed by his garden, and marked, with one eye, How the -Owl and the Panther were sharing a pie--'</i></p> - -<p>[<tt>later editions continued as follows:</tt> <i>The Panther -took pie-crust, and gravy, and meat, While the Owl had the dish -as its share of the treat. When the pie was all finished, the -Owl, as a boon, Was kindly permitted to pocket the spoon: While -the Panther received knife and fork with a growl, And concluded -the banquet--</i>]</p> - -<p>'What <i>is</i> the use of repeating all that stuff,' the Mock Turtle -interrupted, 'if you don't explain it as you go on? It's by far -the most confusing thing I ever heard!'</p> - -<p>'Yes, I think you'd better leave off,' said the Gryphon: and -Alice was only too glad to do so.</p> - -<p>'Shall we try another figure of the Lobster Quadrille?' the -Gryphon went on. 'Or would you like the Mock Turtle to sing you a -song?'</p> - -<p>'Oh, a song, please, if the Mock Turtle would be so kind,' -Alice replied, so eagerly that the Gryphon said, in a rather -offended tone, 'Hm! No accounting for tastes! Sing her "Turtle -Soup," will you, old fellow?'</p> - -<p>The Mock Turtle sighed deeply, and began, in a voice sometimes -choked with sobs, to sing this:--</p> - -<p><i>'Beautiful Soup, so rich and green, Waiting in a hot -tureen! Who for such dainties would not stoop? Soup of the -evening, beautiful Soup! Soup of the evening, beautiful Soup! -Beau--ootiful Soo--oop! Beau--ootiful Soo--oop! Soo--oop of the -e--e--evening, Beautiful, beautiful Soup!</i></p> - -<p><i>'Beautiful Soup! Who cares for fish, Game, or any other -dish? Who would not give all else for two pennyworth only of -beautiful Soup? Pennyworth only of beautiful Soup? Beau--ootiful -Soo--oop! Beau--ootiful Soo--oop! Soo--oop of the e--e--evening, -Beautiful, beauti--FUL SOUP!'</i></p> - -<p>'Chorus again!' cried the Gryphon, and the Mock Turtle had -just begun to repeat it, when a cry of 'The trial's beginning!' -was heard in the distance.</p> - -<p>'Come on!' cried the Gryphon, and, taking Alice by the hand, -it hurried off, without waiting for the end of the song.</p> - -<p>'What trial is it?' Alice panted as she ran; but the Gryphon -only answered 'Come on!' and ran the faster, while more and more -faintly came, carried on the breeze that followed them, the -melancholy words:--</p> - -<p><i>'Soo--oop of the e--e--evening, Beautiful, beautiful -Soup!'</i></p> - -<hr> -<h3 align="Center">CHAPTER XI</h3> - -<h3 align="Center">Who Stole the Tarts?</h3> - -<p>The King and Queen of Hearts were seated on their throne when -they arrived, with a great crowd assembled about them--all sorts -of little birds and beasts, as well as the whole pack of cards: -the Knave was standing before them, in chains, with a soldier on -each side to guard him; and near the King was the White Rabbit, -with a trumpet in one hand, and a scroll of parchment in the -other. In the very middle of the court was a table, with a large -dish of tarts upon it: they looked so good, that it made Alice -quite hungry to look at them--'I wish they'd get the trial done,' -she thought, 'and hand round the refreshments!' But there seemed -to be no chance of this, so she began looking at everything about -her, to pass away the time.</p> - -<p>Alice had never been in a court of justice before, but she had -read about them in books, and she was quite pleased to find that -she knew the name of nearly everything there. 'That's the judge,' -she said to herself, 'because of his great wig.'</p> - -<p>The judge, by the way, was the King; and as he wore his crown -over the wig, (look at the frontispiece if you want to see how he -did it,) he did not look at all comfortable, and it was certainly -not becoming.</p> - -<p>'And that's the jury-box,' thought Alice, 'and those twelve -creatures,' (she was obliged to say 'creatures,' you see, because -some of them were animals, and some were birds,) 'I suppose they -are the jurors.' She said this last word two or three times over -to herself, being rather proud of it: for she thought, and -rightly too, that very few little girls of her age knew the -meaning of it at all. However, 'jury-men' would have done just as -well.</p> - -<p>The twelve jurors were all writing very busily on slates. -'What are they doing?' Alice whispered to the Gryphon. 'They -can't have anything to put down yet, before the trial's -begun.'</p> - -<p>'They're putting down their names,' the Gryphon whispered in -reply, 'for fear they should forget them before the end of the -trial.'</p> - -<p>'Stupid things!' Alice began in a loud, indignant voice, but -she stopped hastily, for the White Rabbit cried out, 'Silence in -the court!' and the King put on his spectacles and looked -anxiously round, to make out who was talking.</p> - -<p>Alice could see, as well as if she were looking over their -shoulders, that all the jurors were writing down 'stupid things!' -on their slates, and she could even make out that one of them -didn't know how to spell 'stupid,' and that he had to ask his -neighbour to tell him. 'A nice muddle their slates'll be in -before the trial's over!' thought Alice.</p> - -<p>One of the jurors had a pencil that squeaked. This of course, -Alice could <i>not</i> stand, and she went round the court and -got behind him, and very soon found an opportunity of taking it -away. She did it so quickly that the poor little juror (it was -Bill, the Lizard) could not make out at all what had become of -it; so, after hunting all about for it, he was obliged to write -with one finger for the rest of the day; and this was of very -little use, as it left no mark on the slate.</p> - -<p>'Herald, read the accusation!' said the King.</p> - -<p>On this the White Rabbit blew three blasts on the trumpet, and -then unrolled the parchment scroll, and read as follows:--</p> - -<p><i>'The Queen of Hearts, she made some tarts, All on a summer -day: The Knave of Hearts, he stole those tarts, And took them -quite away!'</i></p> - -<p>'Consider your verdict,' the King said to the jury.</p> - -<p>'Not yet, not yet!' the Rabbit hastily interrupted. 'There's a -great deal to come before that!'</p> - -<p>'Call the first witness,' said the King; and the White Rabbit -blew three blasts on the trumpet, and called out, 'First -witness!'</p> - -<p>The first witness was the Hatter. He came in with a teacup in -one hand and a piece of bread-and-butter in the other. 'I beg -pardon, your Majesty,' he began, 'for bringing these in: but I -hadn't quite finished my tea when I was sent for.'</p> - -<p>'You ought to have finished,' said the King. 'When did you -begin?'</p> - -<p>The Hatter looked at the March Hare, who had followed him into -the court, arm-in-arm with the Dormouse. 'Fourteenth of March, I -<i>think</i> it was,' he said.</p> - -<p>'Fifteenth,' said the March Hare.</p> - -<p>'Sixteenth,' added the Dormouse.</p> - -<p>'Write that down,' the King said to the jury, and the jury -eagerly wrote down all three dates on their slates, and then -added them up, and reduced the answer to shillings and pence.</p> - -<p>'Take off your hat,' the King said to the Hatter.</p> - -<p>'It isn't mine,' said the Hatter.</p> - -<p>'<i>Stolen!</i>' the King exclaimed, turning to the jury, who -instantly made a memorandum of the fact.</p> - -<p>'I keep them to sell,' the Hatter added as an explanation; -'I've none of my own. I'm a hatter.'</p> - -<p>Here the Queen put on her spectacles, and began staring at the -Hatter, who turned pale and fidgeted.</p> - -<p>'Give your evidence,' said the King; 'and don't be nervous, or -I'll have you executed on the spot.'</p> - -<p>This did not seem to encourage the witness at all: he kept -shifting from one foot to the other, looking uneasily at the -Queen, and in his confusion he bit a large piece out of his -teacup instead of the bread-and-butter.</p> - -<p>Just at this moment Alice felt a very curious sensation, which -puzzled her a good deal until she made out what it was: she was -beginning to grow larger again, and she thought at first she -would get up and leave the court; but on second thoughts she -decided to remain where she was as long as there was room for -her.</p> - -<p>'I wish you wouldn't squeeze so.' said the Dormouse, who was -sitting next to her. 'I can hardly breathe.'</p> - -<p>'I can't help it,' said Alice very meekly: 'I'm growing.'</p> - -<p>'You've no right to grow <i>here</i>,' said the Dormouse.</p> - -<p>'Don't talk nonsense,' said Alice more boldly: 'you know -you're growing too.'</p> - -<p>'Yes, but <i>I</i> grow at a reasonable pace,' said the -Dormouse: 'not in that ridiculous fashion.' And he got up very -sulkily and crossed over to the other side of the court.</p> - -<p>All this time the Queen had never left off staring at the -Hatter, and, just as the Dormouse crossed the court, she said to -one of the officers of the court, 'Bring me the list of the -singers in the last concert!' on which the wretched Hatter -trembled so, that he shook both his shoes off.</p> - -<p>'Give your evidence,' the King repeated angrily, 'or I'll have -you executed, whether you're nervous or not.'</p> - -<p>'I'm a poor man, your Majesty,' the Hatter began, in a -trembling voice, '--and I hadn't begun my tea--not above a week -or so--and what with the bread-and-butter getting so thin--and -the twinkling of the tea--'</p> - -<p>'The twinkling of the <i>what</i>?' said the King.</p> - -<p>'It <i>began</i> with the tea,' the Hatter replied.</p> - -<p>'Of course twinkling <i>begins</i> with a T!' said the King -sharply. 'Do you take me for a dunce? Go on!'</p> - -<p>'I'm a poor man,' the Hatter went on, 'and most things -twinkled after that--only the March Hare said--'</p> - -<p>'I didn't!' the March Hare interrupted in a great hurry.</p> - -<p>'You did!' said the Hatter.</p> - -<p>'I deny it!' said the March Hare.</p> - -<p>'He denies it,' said the King: 'leave out that part.'</p> - -<p>'Well, at any rate, the Dormouse said--' the Hatter went on, -looking anxiously round to see if he would deny it too: but the -Dormouse denied nothing, being fast asleep.</p> - -<p>'After that,' continued the Hatter, 'I cut some more bread- -and-butter--'</p> - -<p>'But what did the Dormouse say?' one of the jury asked.</p> - -<p>'That I can't remember,' said the Hatter.</p> - -<p>'You <i>must</i> remember,' remarked the King, 'or I'll have -you executed.'</p> - -<p>The miserable Hatter dropped his teacup and bread-and-butter, -and went down on one knee. 'I'm a poor man, your Majesty,' he -began.</p> - -<p>'You're a very poor <i>speaker</i>,' said the King.</p> - -<p>Here one of the guinea-pigs cheered, and was immediately -suppressed by the officers of the court. (As that is rather a -hard word, I will just explain to you how it was done. They had a -large canvas bag, which tied up at the mouth with strings: into -this they slipped the guinea-pig, head first, and then sat upon -it.)</p> - -<p>'I'm glad I've seen that done,' thought Alice. 'I've so often -read in the newspapers, at the end of trials, "There was some -attempts at applause, which was immediately suppressed by the -officers of the court," and I never understood what it meant till -now.'</p> - -<p>'If that's all you know about it, you may stand down,' -continued the King.</p> - -<p>'I can't go no lower,' said the Hatter: 'I'm on the floor, as -it is.'</p> - -<p>'Then you may <i>sit</i> down,' the King replied.</p> - -<p>Here the other guinea-pig cheered, and was suppressed.</p> - -<p>'Come, that finished the guinea-pigs!' thought Alice. 'Now we -shall get on better.'</p> - -<p>'I'd rather finish my tea,' said the Hatter, with an anxious -look at the Queen, who was reading the list of singers.</p> - -<p>'You may go,' said the King, and the Hatter hurriedly left the -court, without even waiting to put his shoes on.</p> - -<p>'--and just take his head off outside,' the Queen added to one -of the officers: but the Hatter was out of sight before the -officer could get to the door.</p> - -<p>'Call the next witness!' said the King.</p> - -<p>The next witness was the Duchess's cook. She carried the -pepper-box in her hand, and Alice guessed who it was, even before -she got into the court, by the way the people near the door began -sneezing all at once.</p> - -<p>'Give your evidence,' said the King.</p> - -<p>'Shan't,' said the cook.</p> - -<p>The King looked anxiously at the White Rabbit, who said in a -low voice, 'Your Majesty must cross-examine <i>this</i> witness.'</p> - -<p>'Well, if I must, I must,' the King said, with a melancholy -air, and, after folding his arms and frowning at the cook till -his eyes were nearly out of sight, he said in a deep voice, 'What -are tarts made of?'</p> - -<p>'Pepper, mostly,' said the cook.</p> - -<p>'Treacle,' said a sleepy voice behind her.</p> - -<p>'Collar that Dormouse,' the Queen shrieked out. 'Behead that -Dormouse! Turn that Dormouse out of court! Suppress him! Pinch -him! Off with his whiskers!'</p> - -<p>For some minutes the whole court was in confusion, getting the -Dormouse turned out, and, by the time they had settled down -again, the cook had disappeared.</p> - -<p>'Never mind!' said the King, with an air of great relief. -'Call the next witness.' And he added in an undertone to the -Queen, 'Really, my dear, <i>you</i> must cross-examine the next -witness. It quite makes my forehead ache!'</p> - -<p>Alice watched the White Rabbit as he fumbled over the list, -feeling very curious to see what the next witness would be like, -'--for they haven't got much evidence <i>yet</i>,' she said to -herself. Imagine her surprise, when the White Rabbit read out, at -the top of his shrill little voice, the name 'Alice!'</p> - -<hr> -<h3 align="Center">CHAPTER XII</h3> - -<h3 align="Center">Alice's Evidence</h3> - -<p>'Here!' cried Alice, quite forgetting in the flurry of the -moment how large she had grown in the last few minutes, and she -jumped up in such a hurry that she tipped over the jury-box with -the edge of her skirt, upsetting all the jurymen on to the heads -of the crowd below, and there they lay sprawling about, reminding -her very much of a globe of goldfish she had accidentally upset -the week before.</p> - -<p>'Oh, I <i>beg</i> your pardon!' she exclaimed in a tone of -great dismay, and began picking them up again as quickly as she -could, for the accident of the goldfish kept running in her head, -and she had a vague sort of idea that they must be collected at -once and put back into the jury-box, or they would die.</p> - -<p>'The trial cannot proceed,' said the King in a very grave -voice, 'until all the jurymen are back in their proper places-- -<i>all</i>,' he repeated with great emphasis, looking hard at -Alice as he said do.</p> - -<p>Alice looked at the jury-box, and saw that, in her haste, she -had put the Lizard in head downwards, and the poor little thing -was waving its tail about in a melancholy way, being quite unable -to move. She soon got it out again, and put it right; 'not that -it signifies much,' she said to herself; 'I should think it would -be <i>quite</i> as much use in the trial one way up as the -other.'</p> - -<p>As soon as the jury had a little recovered from the shock of -being upset, and their slates and pencils had been found and -handed back to them, they set to work very diligently to write -out a history of the accident, all except the Lizard, who seemed -too much overcome to do anything but sit with its mouth open, -gazing up into the roof of the court.</p> - -<p>'What do you know about this business?' the King said to -Alice.</p> - -<p>'Nothing,' said Alice.</p> - -<p>'Nothing <i>whatever?</i>' persisted the King.</p> - -<p>'Nothing <i>whatever,</i>' said Alice.</p> - -<p>'That's very important,' the King said, turning to the jury. -They were just beginning to write this down on their slates, when -the White Rabbit interrupted: '<i>Un</i>important, your Majesty -means, of course,' he said in a very respectful tone, but -frowning and making faces at him as he spoke.</p> - -<p>'<i>Un</i>important, of course, I meant,' the King hastily -said, and went on to himself in an undertone, -'important--unimportant-- unimportant--important--' as if he were -trying which word sounded best.</p> - -<p>Some of the jury wrote it down 'important,' and some -'unimportant.' Alice could see this, as she was near enough to -look over their slates; 'but it doesn't matter a bit,' she -thought to herself.</p> - -<p>At this moment the King, who had been for some time busily -writing in his note-book, cackled out 'Silence!' and read out -from his book, 'Rule Forty-two. <i>All persons more than a mile -hight to leave the court</i>.'</p> - -<p>Everybody looked at Alice.</p> - -<p>'<i>I'm</i> not a mile high,' said Alice.</p> - -<p>'You are,' said the King.</p> - -<p>'Nearly two miles high,' added the Queen.</p> - -<p>'Well, I shan't go, at any rate,' said Alice: 'besides, that's -not a regular rule: you invented it just now.'</p> - -<p>'It's the oldest rule in the book,' said the King.</p> - -<p>'Then it ought to be Number One,' said Alice.</p> - -<p>The King turned pale, and shut his note-book hastily. -'Consider your verdict,' he said to the jury, in a low, trembling -voice.</p> - -<p>'There's more evidence to come yet, please your Majesty,' said -the White Rabbit, jumping up in a great hurry; 'this paper has -just been picked up.'</p> - -<p>'What's in it?' said the Queen.</p> - -<p>'I haven't opened it yet,' said the White Rabbit, 'but it -seems to be a letter, written by the prisoner to--to -somebody.'</p> - -<p>'It must have been that,' said the King, 'unless it was -written to nobody, which isn't usual, you know.'</p> - -<p>'Who is it directed to?' said one of the jurymen.</p> - -<p>'It isn't directed at all,' said the White Rabbit; 'in fact, -there's nothing written on the <i>outside</i>.' He unfolded the -paper as he spoke, and added 'It isn't a letter, after all: it's -a set of verses.'</p> - -<p>'Are they in the prisoner's handwriting?' asked another of -they jurymen.</p> - -<p>'No, they're not,' said the White Rabbit, 'and that's the -queerest thing about it.' (The jury all looked puzzled.)</p> - -<p>'He must have imitated somebody else's hand,' said the King. -(The jury all brightened up again.)</p> - -<p>'Please your Majesty,' said the Knave, 'I didn't write it, and -they can't prove I did: there's no name signed at the end.'</p> - -<p>'If you didn't sign it,' said the King, 'that only makes the -matter worse. You <i>must</i> have meant some mischief, or else -you'd have signed your name like an honest man.'</p> - -<p>There was a general clapping of hands at this: it was the -first really clever thing the King had said that day.</p> - -<p>'That <i>proves</i> his guilt,' said the Queen.</p> - -<p>'It proves nothing of the sort!' said Alice. 'Why, you don't -even know what they're about!'</p> - -<p>'Read them,' said the King.</p> - -<p>The White Rabbit put on his spectacles. 'Where shall I begin, -please your Majesty?' he asked.</p> - -<p>'Begin at the beginning,' the King said gravely, 'and go on -till you come to the end: then stop.'</p> - -<p>These were the verses the White Rabbit read:--</p> - -<p><i>'They told me you had been to her, And mentioned me to him: -She gave me a good character, But said I could not swim.</i></p> - -<p><i>He sent them word I had not gone (We know it to be true): -If she should push the matter on, What would become of -you?</i></p> - -<p><i>I gave her one, they gave him two, You gave us three or -more; They all returned from him to you, Though they were mine -before.</i></p> - -<p><i>If I or she should chance to be Involved in this affair, He -trusts to you to set them free, Exactly as we were.</i></p> - -<p><i>My notion was that you had been (Before she had this fit) -An obstacle that came between Him, and ourselves, and it.</i></p> - -<p><i>Don't let him know she liked them best, For this must ever -be A secret, kept from all the rest, Between yourself and -me.'</i></p> - -<p>'That's the most important piece of evidence we've heard yet,' -said the King, rubbing his hands; 'so now let the jury--'</p> - -<p>'If any one of them can explain it,' said Alice, (she had -grown so large in the last few minutes that she wasn't a bit -afraid of interrupting him,) 'I'll give him sixpence. _I_ don't -believe there's an atom of meaning in it.'</p> - -<p>The jury all wrote down on their slates, '<i>She</i> doesn't -believe there's an atom of meaning in it,' but none of them -attempted to explain the paper.</p> - -<p>'If there's no meaning in it,' said the King, 'that saves a -world of trouble, you know, as we needn't try to find any. And -yet I don't know,' he went on, spreading out the verses on his -knee, and looking at them with one eye; 'I seem to see some -meaning in them, after all. "<i>-said I could not swim--</i>" you -can't swim, can you?' he added, turning to the Knave.</p> - -<p>The Knave shook his head sadly. 'Do I look like it?' he said. -(Which he certainly did <i>not</i>, being made entirely of -cardboard.)</p> - -<p>'All right, so far,' said the King, and he went on muttering -over the verses to himself: '"<i>We know it to be true--</i>" -that's the jury, of course-- "<i>I gave her one, they gave him -two--</i>" why, that must be what he did with the tarts, you -know--'</p> - -<p>'But, it goes on "<i>they all returned from him to you,</i>"' -said Alice.</p> - -<p>'Why, there they are!' said the King triumphantly, pointing to -the tarts on the table. 'Nothing can be clearer than <i>that</i>. -Then again--"<i>before she had this fit-</i>-" you never had -<i>fits</i>, my dear, I think?' he said to the Queen.</p> - -<p>'Never!' said the Queen furiously, throwing an inkstand at the -Lizard as she spoke. (The unfortunate little Bill had left off -writing on his slate with one finger, as he found it made no -mark; but he now hastily began again, using the ink, that was -trickling down his face, as long as it lasted.)</p> - -<p>'Then the words don't <i>fit</i> you,' said the King, looking -round the court with a smile. There was a dead silence.</p> - -<p>'It's a pun!' the King added in an offended tone, and -everybody laughed, 'Let the jury consider their verdict,' the -King said, for about the twentieth time that day.</p> - -<p>'No, no!' said the Queen. 'Sentence first--verdict -afterwards.'</p> - -<p>'Stuff and nonsense!' said Alice loudly. 'The idea of having -the sentence first!'</p> - -<p>'Hold your tongue!' said the Queen, turning purple.</p> - -<p>'I won't!' said Alice.</p> - -<p>'Off with her head!' the Queen shouted at the top of her -voice. Nobody moved.</p> - -<p>'Who cares for you?' said Alice, (she had grown to her full -size by this time.) 'You're nothing but a pack of cards!'</p> - -<p>At this the whole pack rose up into the air, and came flying -down upon her: she gave a little scream, half of fright and half -of anger, and tried to beat them off, and found herself lying on -the bank, with her head in the lap of her sister, who was gently -brushing away some dead leaves that had fluttered down from the -trees upon her face.</p> - -<p>'Wake up, Alice dear!' said her sister; 'Why, what a long -sleep you've had!'</p> - -<p>'Oh, I've had such a curious dream!' said Alice, and she told -her sister, as well as she could remember them, all these strange -Adventures of hers that you have just been reading about; and -when she had finished, her sister kissed her, and said, 'It -<i>was</i> a curious dream, dear, certainly: but now run in to -your tea; it's getting late.' So Alice got up and ran off, -thinking while she ran, as well she might, what a wonderful dream -it had been.</p> - -<p>But her sister sat still just as she left her, leaning her -head on her hand, watching the setting sun, and thinking of -little Alice and all her wonderful Adventures, till she too began -dreaming after a fashion, and this was her dream:--</p> - -<p>First, she dreamed of little Alice herself, and once again the -tiny hands were clasped upon her knee, and the bright eager eyes -were looking up into hers--she could hear the very tones of her -voice, and see that queer little toss of her head to keep back -the wandering hair that <i>would</i> always get into her -eyes--and still as she listened, or seemed to listen, the whole -place around her became alive the strange creatures of her little -sister's dream.</p> - -<p>The long grass rustled at her feet as the White Rabbit hurried -by--the frightened Mouse splashed his way through the -neighbouring pool--she could hear the rattle of the teacups as -the March Hare and his friends shared their never-ending meal, -and the shrill voice of the Queen ordering off her unfortunate -guests to execution--once more the pig-baby was sneezing on the -Duchess's knee, while plates and dishes crashed around it--once -more the shriek of the Gryphon, the squeaking of the Lizard's -slate-pencil, and the choking of the suppressed guinea-pigs, -filled the air, mixed up with the distant sobs of the miserable -Mock Turtle.</p> - -<p>So she sat on, with closed eyes, and half believed herself in -Wonderland, though she knew she had but to open them again, and -all would change to dull reality--the grass would be only -rustling in the wind, and the pool rippling to the waving of the -reeds--the rattling teacups would change to tinkling sheep-bells, -and the Queen's shrill cries to the voice of the shepherd -boy--and the sneeze of the baby, the shriek of the Gryphon, and -all the other queer noises, would change (she knew) to the -confused clamour of the busy farm-yard--while the lowing of the -cattle in the distance would take the place of the Mock Turtle's -heavy sobs.</p> - -<p>Lastly, she pictured to herself how this same little sister of -hers would, in the after-time, be herself a grown woman; and how -she would keep, through all her riper years, the simple and -loving heart of her childhood: and how she would gather about her -other little children, and make <i>their</i> eyes bright and eager with -many a strange tale, perhaps even with the dream of Wonderland of -long ago: and how she would feel with all their simple sorrows, -and find a pleasure in all their simple joys, remembering her own -child-life, and the happy summer days.</p> - -<p>End of the Project Gutenberg Etext of Alice's Adventures in -Wonderland</p> - -</body> -</html> diff --git a/deps/node/benchmark/fixtures/echo.worker.js b/deps/node/benchmark/fixtures/echo.worker.js deleted file mode 100644 index 167a28ad..00000000 --- a/deps/node/benchmark/fixtures/echo.worker.js +++ /dev/null @@ -1,7 +0,0 @@ -'use strict'; - -const { parentPort } = require('worker_threads'); - -parentPort.on('message', (msg) => { - parentPort.postMessage(msg); -}); diff --git a/deps/node/benchmark/fixtures/require-cachable.js b/deps/node/benchmark/fixtures/require-cachable.js deleted file mode 100644 index f651728d..00000000 --- a/deps/node/benchmark/fixtures/require-cachable.js +++ /dev/null @@ -1,13 +0,0 @@ -'use strict'; - -const list = require('internal/bootstrap/cache'); -const { - isMainThread -} = require('worker_threads'); - -for (const key of list.cachableBuiltins) { - if (!isMainThread && key === 'trace_events') { - continue; - } - require(key); -} diff --git a/deps/node/benchmark/fixtures/simple-http-server.js b/deps/node/benchmark/fixtures/simple-http-server.js deleted file mode 100644 index 0eb7d9ee..00000000 --- a/deps/node/benchmark/fixtures/simple-http-server.js +++ /dev/null @@ -1,138 +0,0 @@ -'use strict'; - -const http = require('http'); - -const fixed = 'C'.repeat(20 * 1024); -const storedBytes = Object.create(null); -const storedBuffer = Object.create(null); -const storedUnicode = Object.create(null); - -const useDomains = process.env.NODE_USE_DOMAINS; - -// set up one global domain. -if (useDomains) { - var domain = require('domain'); - const gdom = domain.create(); - gdom.on('error', (er) => { - console.error('Error on global domain', er); - throw er; - }); - gdom.enter(); -} - -module.exports = http.createServer((req, res) => { - if (useDomains) { - const dom = domain.create(); - dom.add(req); - dom.add(res); - } - - // URL format: /<type>/<length>/<chunks>/<responseBehavior>/chunkedEnc - const params = req.url.split('/'); - const command = params[1]; - var body = ''; - const arg = params[2]; - const n_chunks = parseInt(params[3], 10); - const resHow = params.length >= 5 ? params[4] : 'normal'; - const chunkedEnc = params.length >= 6 && params[5] === '0' ? false : true; - var status = 200; - - var n, i; - if (command === 'bytes') { - n = ~~arg; - if (n <= 0) - throw new Error('bytes called with n <= 0'); - if (storedBytes[n] === undefined) { - storedBytes[n] = 'C'.repeat(n); - } - body = storedBytes[n]; - } else if (command === 'buffer') { - n = ~~arg; - if (n <= 0) - throw new Error('buffer called with n <= 0'); - if (storedBuffer[n] === undefined) { - storedBuffer[n] = Buffer.allocUnsafe(n); - for (i = 0; i < n; i++) { - storedBuffer[n][i] = 'C'.charCodeAt(0); - } - } - body = storedBuffer[n]; - } else if (command === 'unicode') { - n = ~~arg; - if (n <= 0) - throw new Error('unicode called with n <= 0'); - if (storedUnicode[n] === undefined) { - storedUnicode[n] = '\u263A'.repeat(n); - } - body = storedUnicode[n]; - } else if (command === 'quit') { - res.connection.server.close(); - body = 'quitting'; - } else if (command === 'fixed') { - body = fixed; - } else if (command === 'echo') { - switch (resHow) { - case 'setHeader': - res.statusCode = 200; - res.setHeader('Content-Type', 'text/plain'); - res.setHeader('Transfer-Encoding', 'chunked'); - break; - case 'setHeaderWH': - res.setHeader('Content-Type', 'text/plain'); - res.writeHead(200, { 'Transfer-Encoding': 'chunked' }); - break; - default: - res.writeHead(200, { - 'Content-Type': 'text/plain', - 'Transfer-Encoding': 'chunked' - }); - } - req.pipe(res); - return; - } else { - status = 404; - body = 'not found\n'; - } - - // example: http://localhost:port/bytes/512/4 - // sends a 512 byte body in 4 chunks of 128 bytes - const len = body.length; - switch (resHow) { - case 'setHeader': - res.statusCode = status; - res.setHeader('Content-Type', 'text/plain'); - if (chunkedEnc) - res.setHeader('Transfer-Encoding', 'chunked'); - else - res.setHeader('Content-Length', len.toString()); - break; - case 'setHeaderWH': - res.setHeader('Content-Type', 'text/plain'); - if (chunkedEnc) - res.writeHead(status, { 'Transfer-Encoding': 'chunked' }); - else - res.writeHead(status, { 'Content-Length': len.toString() }); - break; - default: - if (chunkedEnc) { - res.writeHead(status, { - 'Content-Type': 'text/plain', - 'Transfer-Encoding': 'chunked' - }); - } else { - res.writeHead(status, { - 'Content-Type': 'text/plain', - 'Content-Length': len.toString() - }); - } - } - // send body in chunks - if (n_chunks > 1) { - const step = Math.floor(len / n_chunks) || 1; - for (i = 0, n = (n_chunks - 1); i < n; ++i) - res.write(body.slice(i * step, i * step + step)); - res.end(body.slice((n_chunks - 1) * step)); - } else { - res.end(body); - } -}); diff --git a/deps/node/benchmark/fs/bench-mkdirp.js b/deps/node/benchmark/fs/bench-mkdirp.js deleted file mode 100644 index b9e62045..00000000 --- a/deps/node/benchmark/fs/bench-mkdirp.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); -const tmpdir = require('../../test/common/tmpdir'); -tmpdir.refresh(); -let dirc = 0; - -const bench = common.createBenchmark(main, { - n: [1e4], -}); - -function main({ n }) { - bench.start(); - (function r(cntr) { - if (cntr-- <= 0) - return bench.end(n); - const pathname = `${tmpdir.path}/${++dirc}/${++dirc}/${++dirc}/${++dirc}`; - fs.mkdir(pathname, { recursive: true }, (err) => { - r(cntr); - }); - }(n)); -} diff --git a/deps/node/benchmark/fs/bench-readdir.js b/deps/node/benchmark/fs/bench-readdir.js deleted file mode 100644 index 3731e35a..00000000 --- a/deps/node/benchmark/fs/bench-readdir.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); -const path = require('path'); - -const bench = common.createBenchmark(main, { - n: [10], - dir: [ 'lib', 'test/parallel'], - withFileTypes: ['true', 'false'] -}); - -function main({ n, dir, withFileTypes }) { - withFileTypes = withFileTypes === 'true'; - const fullPath = path.resolve(__dirname, '../../', dir); - bench.start(); - (function r(cntr) { - if (cntr-- <= 0) - return bench.end(n); - fs.readdir(fullPath, { withFileTypes }, () => { - r(cntr); - }); - }(n)); -} diff --git a/deps/node/benchmark/fs/bench-readdirSync.js b/deps/node/benchmark/fs/bench-readdirSync.js deleted file mode 100644 index 5d0e9739..00000000 --- a/deps/node/benchmark/fs/bench-readdirSync.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); -const path = require('path'); - -const bench = common.createBenchmark(main, { - n: [10], - dir: [ 'lib', 'test/parallel'], - withFileTypes: ['true', 'false'] -}); - - -function main({ n, dir, withFileTypes }) { - withFileTypes = withFileTypes === 'true'; - const fullPath = path.resolve(__dirname, '../../', dir); - bench.start(); - for (var i = 0; i < n; i++) { - fs.readdirSync(fullPath, { withFileTypes }); - } - bench.end(n); -} diff --git a/deps/node/benchmark/fs/bench-realpath.js b/deps/node/benchmark/fs/bench-realpath.js deleted file mode 100644 index 97148437..00000000 --- a/deps/node/benchmark/fs/bench-realpath.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); -const path = require('path'); -const resolved_path = path.resolve(__dirname, '../../lib/'); -const relative_path = path.relative(__dirname, '../../lib/'); - -const bench = common.createBenchmark(main, { - n: [1e4], - pathType: ['relative', 'resolved'], -}); - - -function main({ n, pathType }) { - bench.start(); - if (pathType === 'relative') - relativePath(n); - else - resolvedPath(n); -} - -function relativePath(n) { - (function r(cntr) { - if (cntr-- <= 0) - return bench.end(n); - fs.realpath(relative_path, () => { - r(cntr); - }); - }(n)); -} - -function resolvedPath(n) { - (function r(cntr) { - if (cntr-- <= 0) - return bench.end(n); - fs.realpath(resolved_path, () => { - r(cntr); - }); - }(n)); -} diff --git a/deps/node/benchmark/fs/bench-realpathSync.js b/deps/node/benchmark/fs/bench-realpathSync.js deleted file mode 100644 index 7a01bd18..00000000 --- a/deps/node/benchmark/fs/bench-realpathSync.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); -const path = require('path'); - -process.chdir(__dirname); -const resolved_path = path.resolve(__dirname, '../../lib/'); -const relative_path = path.relative(__dirname, '../../lib/'); - -const bench = common.createBenchmark(main, { - n: [1e4], - pathType: ['relative', 'resolved'], -}); - - -function main({ n, pathType }) { - const path = pathType === 'relative' ? relative_path : resolved_path; - bench.start(); - for (var i = 0; i < n; i++) { - fs.realpathSync(path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/fs/bench-stat-promise.js b/deps/node/benchmark/fs/bench-stat-promise.js deleted file mode 100644 index 99a5da57..00000000 --- a/deps/node/benchmark/fs/bench-stat-promise.js +++ /dev/null @@ -1,28 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fsPromises = require('fs').promises; - -const bench = common.createBenchmark(main, { - n: [20e4], - statType: ['fstat', 'lstat', 'stat'] -}); - -async function run(n, statType) { - const handleMode = statType === 'fstat'; - const arg = handleMode ? await fsPromises.open(__filename, 'r') : __filename; - let remaining = n; - bench.start(); - while (remaining-- > 0) - await (handleMode ? arg.stat() : fsPromises[statType](arg)); - bench.end(n); - - if (typeof arg.close === 'function') - await arg.close(); -} - -function main(conf) { - const n = conf.n >>> 0; - const statType = conf.statType; - run(n, statType).catch(console.log); -} diff --git a/deps/node/benchmark/fs/bench-stat.js b/deps/node/benchmark/fs/bench-stat.js deleted file mode 100644 index 0b2e1972..00000000 --- a/deps/node/benchmark/fs/bench-stat.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); - -const bench = common.createBenchmark(main, { - n: [20e4], - statType: ['fstat', 'lstat', 'stat'] -}); - - -function main({ n, statType }) { - var arg; - if (statType === 'fstat') - arg = fs.openSync(__filename, 'r'); - else - arg = __filename; - - bench.start(); - (function r(cntr, fn) { - if (cntr-- <= 0) { - bench.end(n); - if (statType === 'fstat') - fs.closeSync(arg); - return; - } - fn(arg, () => { - r(cntr, fn); - }); - }(n, fs[statType])); -} diff --git a/deps/node/benchmark/fs/bench-statSync.js b/deps/node/benchmark/fs/bench-statSync.js deleted file mode 100644 index bd8754a6..00000000 --- a/deps/node/benchmark/fs/bench-statSync.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const common = require('../common'); -const fs = require('fs'); - -const bench = common.createBenchmark(main, { - n: [1e6], - statSyncType: ['fstatSync', 'lstatSync', 'statSync'] -}); - - -function main({ n, statSyncType }) { - const arg = (statSyncType === 'fstatSync' ? - fs.openSync(__filename, 'r') : - __dirname); - const fn = fs[statSyncType]; - - bench.start(); - for (var i = 0; i < n; i++) { - fn(arg); - } - bench.end(n); - - if (statSyncType === 'fstat') - fs.closeSync(arg); -} diff --git a/deps/node/benchmark/fs/read-stream-throughput.js b/deps/node/benchmark/fs/read-stream-throughput.js deleted file mode 100644 index cb5d98dc..00000000 --- a/deps/node/benchmark/fs/read-stream-throughput.js +++ /dev/null @@ -1,90 +0,0 @@ -// Test the throughput of the fs.WriteStream class. -'use strict'; - -const path = require('path'); -const common = require('../common.js'); -const filename = path.resolve(process.env.NODE_TMPDIR || __dirname, - `.removeme-benchmark-garbage-${process.pid}`); -const fs = require('fs'); -const assert = require('assert'); - -let encodingType, encoding, size, filesize; - -const bench = common.createBenchmark(main, { - encodingType: ['buf', 'asc', 'utf'], - filesize: [1000 * 1024 * 1024], - size: [1024, 4096, 65535, 1024 * 1024] -}); - -function main(conf) { - encodingType = conf.encodingType; - size = conf.size; - filesize = conf.filesize; - - switch (encodingType) { - case 'buf': - encoding = null; - break; - case 'asc': - encoding = 'ascii'; - break; - case 'utf': - encoding = 'utf8'; - break; - default: - throw new Error(`invalid encodingType: ${encodingType}`); - } - - makeFile(); -} - -function runTest() { - assert(fs.statSync(filename).size === filesize); - const rs = fs.createReadStream(filename, { - highWaterMark: size, - encoding: encoding - }); - - rs.on('open', () => { - bench.start(); - }); - - var bytes = 0; - rs.on('data', (chunk) => { - bytes += chunk.length; - }); - - rs.on('end', () => { - try { fs.unlinkSync(filename); } catch {} - // MB/sec - bench.end(bytes / (1024 * 1024)); - }); -} - -function makeFile() { - const buf = Buffer.allocUnsafe(filesize / 1024); - if (encoding === 'utf8') { - // ü - for (var i = 0; i < buf.length; i++) { - buf[i] = i % 2 === 0 ? 0xC3 : 0xBC; - } - } else if (encoding === 'ascii') { - buf.fill('a'); - } else { - buf.fill('x'); - } - - try { fs.unlinkSync(filename); } catch {} - var w = 1024; - const ws = fs.createWriteStream(filename); - ws.on('close', runTest); - ws.on('drain', write); - write(); - function write() { - do { - w--; - } while (false !== ws.write(buf) && w > 0); - if (w === 0) - ws.end(); - } -} diff --git a/deps/node/benchmark/fs/readFileSync.js b/deps/node/benchmark/fs/readFileSync.js deleted file mode 100644 index c28adeb2..00000000 --- a/deps/node/benchmark/fs/readFileSync.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const fs = require('fs'); - -const bench = common.createBenchmark(main, { - n: [60e4] -}); - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; ++i) - fs.readFileSync(__filename); - bench.end(n); -} diff --git a/deps/node/benchmark/fs/readfile-partitioned.js b/deps/node/benchmark/fs/readfile-partitioned.js deleted file mode 100644 index 2775793e..00000000 --- a/deps/node/benchmark/fs/readfile-partitioned.js +++ /dev/null @@ -1,86 +0,0 @@ -// Submit a mix of short and long jobs to the threadpool. -// Report total job throughput. -// If we partition the long job, overall job throughput goes up significantly. -// However, this comes at the cost of the long job throughput. -// -// Short jobs: small zip jobs. -// Long jobs: fs.readFile on a large file. - -'use strict'; - -const path = require('path'); -const common = require('../common.js'); -const filename = path.resolve(__dirname, - `.removeme-benchmark-garbage-${process.pid}`); -const fs = require('fs'); -const zlib = require('zlib'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - dur: [5], - len: [1024, 16 * 1024 * 1024], - concurrent: [1, 10] -}); - -function main(conf) { - const len = +conf.len; - try { fs.unlinkSync(filename); } catch {} - var data = Buffer.alloc(len, 'x'); - fs.writeFileSync(filename, data); - data = null; - - var zipData = Buffer.alloc(1024, 'a'); - - var reads = 0; - var zips = 0; - var benchEnded = false; - bench.start(); - setTimeout(() => { - const totalOps = reads + zips; - benchEnded = true; - bench.end(totalOps); - try { fs.unlinkSync(filename); } catch {} - }, +conf.dur * 1000); - - function read() { - fs.readFile(filename, afterRead); - } - - function afterRead(er, data) { - if (er) { - if (er.code === 'ENOENT') { - // Only OK if unlinked by the timer from main. - assert.ok(benchEnded); - return; - } - throw er; - } - - if (data.length !== len) - throw new Error('wrong number of bytes returned'); - - reads++; - if (!benchEnded) - read(); - } - - function zip() { - zlib.deflate(zipData, afterZip); - } - - function afterZip(er, data) { - if (er) - throw er; - - zips++; - if (!benchEnded) - zip(); - } - - // Start reads - var cur = +conf.concurrent; - while (cur--) read(); - - // Start a competing zip - zip(); -} diff --git a/deps/node/benchmark/fs/readfile.js b/deps/node/benchmark/fs/readfile.js deleted file mode 100644 index 551804b1..00000000 --- a/deps/node/benchmark/fs/readfile.js +++ /dev/null @@ -1,58 +0,0 @@ -// Call fs.readFile over and over again really fast. -// Then see how many times it got called. -// Yes, this is a silly benchmark. Most benchmarks are silly. -'use strict'; - -const path = require('path'); -const common = require('../common.js'); -const filename = path.resolve(process.env.NODE_TMPDIR || __dirname, - `.removeme-benchmark-garbage-${process.pid}`); -const fs = require('fs'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - dur: [5], - len: [1024, 16 * 1024 * 1024], - concurrent: [1, 10] -}); - -function main({ len, dur, concurrent }) { - try { fs.unlinkSync(filename); } catch {} - var data = Buffer.alloc(len, 'x'); - fs.writeFileSync(filename, data); - data = null; - - var reads = 0; - var benchEnded = false; - bench.start(); - setTimeout(() => { - benchEnded = true; - bench.end(reads); - try { fs.unlinkSync(filename); } catch {} - process.exit(0); - }, dur * 1000); - - function read() { - fs.readFile(filename, afterRead); - } - - function afterRead(er, data) { - if (er) { - if (er.code === 'ENOENT') { - // Only OK if unlinked by the timer from main. - assert.ok(benchEnded); - return; - } - throw er; - } - - if (data.length !== len) - throw new Error('wrong number of bytes returned'); - - reads++; - if (!benchEnded) - read(); - } - - while (concurrent--) read(); -} diff --git a/deps/node/benchmark/fs/write-stream-throughput.js b/deps/node/benchmark/fs/write-stream-throughput.js deleted file mode 100644 index bc883309..00000000 --- a/deps/node/benchmark/fs/write-stream-throughput.js +++ /dev/null @@ -1,69 +0,0 @@ -// Test the throughput of the fs.WriteStream class. -'use strict'; - -const path = require('path'); -const common = require('../common.js'); -const filename = path.resolve(process.env.NODE_TMPDIR || __dirname, - `.removeme-benchmark-garbage-${process.pid}`); -const fs = require('fs'); - -const bench = common.createBenchmark(main, { - dur: [5], - encodingType: ['buf', 'asc', 'utf'], - size: [2, 1024, 65535, 1024 * 1024] -}); - -function main({ dur, encodingType, size }) { - var encoding; - - var chunk; - switch (encodingType) { - case 'buf': - chunk = Buffer.alloc(size, 'b'); - break; - case 'asc': - chunk = 'a'.repeat(size); - encoding = 'ascii'; - break; - case 'utf': - chunk = 'ü'.repeat(Math.ceil(size / 2)); - encoding = 'utf8'; - break; - default: - throw new Error(`invalid encodingType: ${encodingType}`); - } - - try { fs.unlinkSync(filename); } catch {} - - var started = false; - var ended = false; - - var f = fs.createWriteStream(filename); - f.on('drain', write); - f.on('open', write); - f.on('close', done); - f.on('finish', () => { - ended = true; - const written = fs.statSync(filename).size / 1024; - try { fs.unlinkSync(filename); } catch {} - bench.end(written / 1024); - }); - - - function write() { - if (!started) { - started = true; - setTimeout(() => { - f.end(); - }, dur * 1000); - bench.start(); - } - - while (false !== f.write(chunk, encoding)); - } - - function done() { - if (!ended) - f.emit('finish'); - } -} diff --git a/deps/node/benchmark/http/_chunky_http_client.js b/deps/node/benchmark/http/_chunky_http_client.js deleted file mode 100644 index 21418a7c..00000000 --- a/deps/node/benchmark/http/_chunky_http_client.js +++ /dev/null @@ -1,95 +0,0 @@ -'use strict'; - -// test HTTP throughput in fragmented header case -const common = require('../common.js'); -const net = require('net'); - -const bench = common.createBenchmark(main, { - len: [1, 4, 8, 16, 32, 64, 128], - n: [5, 50, 500, 2000], - type: ['send'], -}); - - -function main({ len, n }) { - var todo = []; - const headers = []; - // Chose 7 because 9 showed "Connection error" / "Connection closed" - // An odd number could result in a better length dispersion. - for (var i = 7; i <= 7 * 7 * 7; i *= 7) - headers.push('o'.repeat(i)); - - function WriteHTTPHeaders(channel, has_keep_alive, extra_header_count) { - todo = []; - todo.push('GET / HTTP/1.1'); - todo.push('Host: localhost'); - todo.push('Connection: keep-alive'); - todo.push('Accept: text/html,application/xhtml+xml,' + - 'application/xml;q=0.9,image/webp,*/*;q=0.8'); - todo.push('User-Agent: Mozilla/5.0 (X11; Linux x86_64) ' + - 'AppleWebKit/537.36 (KHTML, like Gecko) ' + - 'Chrome/39.0.2171.71 Safari/537.36'); - todo.push('Accept-Encoding: gzip, deflate, sdch'); - todo.push('Accept-Language: en-US,en;q=0.8'); - for (var i = 0; i < extra_header_count; i++) { - // Utilize first three powers of a small integer for an odd cycle and - // because the fourth power of some integers overloads the server. - todo.push(`X-Header-${i}: ${headers[i % 3]}`); - } - todo.push(''); - todo.push(''); - todo = todo.join('\r\n'); - // Using odd numbers in many places may increase length coverage. - const chunksize = 37; - for (i = 0; i < todo.length; i += chunksize) { - const cur = todo.slice(i, i + chunksize); - channel.write(cur); - } - } - - const min = 10; - var size = 0; - const mod = 317; - const mult = 17; - const add = 11; - var count = 0; - const PIPE = process.env.PIPE_NAME; - var socket = net.connect(PIPE, () => { - bench.start(); - WriteHTTPHeaders(socket, 1, len); - socket.setEncoding('utf8'); - socket.on('data', (d) => { - var did = false; - var pattern = 'HTTP/1.1 200 OK\r\n'; - if ((d.length === pattern.length && d === pattern) || - (d.length > pattern.length && - d.slice(0, pattern.length) === pattern)) { - did = true; - } else { - pattern = 'HTTP/1.1 '; - if ((d.length === pattern.length && d === pattern) || - (d.length > pattern.length && - d.slice(0, pattern.length) === pattern)) { - did = true; - } - } - size = (size * mult + add) % mod; - if (did) { - count += 1; - if (count === n) { - bench.end(count); - process.exit(0); - } else { - WriteHTTPHeaders(socket, 1, min + size); - } - } - }); - socket.on('close', () => { - console.log('Connection closed'); - }); - - socket.on('error', () => { - throw new Error('Connection error'); - }); - }); -} diff --git a/deps/node/benchmark/http/bench-parser.js b/deps/node/benchmark/http/bench-parser.js deleted file mode 100644 index a54f0efa..00000000 --- a/deps/node/benchmark/http/bench-parser.js +++ /dev/null @@ -1,53 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const bench = common.createBenchmark(main, { - len: [4, 8, 16, 32], - n: [1e5] -}, { - flags: ['--expose-internals', '--no-warnings'] -}); - -function main({ len, n }) { - const { HTTPParser } = common.binding('http_parser'); - const REQUEST = HTTPParser.REQUEST; - const kOnHeaders = HTTPParser.kOnHeaders | 0; - const kOnHeadersComplete = HTTPParser.kOnHeadersComplete | 0; - const kOnBody = HTTPParser.kOnBody | 0; - const kOnMessageComplete = HTTPParser.kOnMessageComplete | 0; - const CRLF = '\r\n'; - - function processHeader(header, n) { - const parser = newParser(REQUEST); - - bench.start(); - for (var i = 0; i < n; i++) { - parser.execute(header, 0, header.length); - parser.reinitialize(REQUEST, i > 0); - } - bench.end(n); - } - - function newParser(type) { - const parser = new HTTPParser(type); - - parser.headers = []; - - parser[kOnHeaders] = function() { }; - parser[kOnHeadersComplete] = function() { }; - parser[kOnBody] = function() { }; - parser[kOnMessageComplete] = function() { }; - - return parser; - } - - let header = `GET /hello HTTP/1.1${CRLF}Content-Type: text/plain${CRLF}`; - - for (var i = 0; i < len; i++) { - header += `X-Filler${i}: ${Math.random().toString(36).substr(2)}${CRLF}`; - } - header += CRLF; - - processHeader(Buffer.from(header), n); -} diff --git a/deps/node/benchmark/http/check_invalid_header_char.js b/deps/node/benchmark/http/check_invalid_header_char.js deleted file mode 100644 index 46ca9f3d..00000000 --- a/deps/node/benchmark/http/check_invalid_header_char.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const _checkInvalidHeaderChar = require('_http_common')._checkInvalidHeaderChar; - -const groupedInputs = { - // Representative set of inputs from an AcmeAir benchmark run: - // all valid strings, average length 14.4, stdev 13.0 - group_acmeair: [ - 'W/"2-d4cbb29"', 'OK', 'Express', 'X-HTTP-Method-Override', 'Express', - 'application/json', 'application/json; charset=utf-8', '206', 'OK', - 'sessionid=; Path=/', 'text/html; charset=utf-8', - 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express', - 'application/json', 'application/json; charset=utf-8', '2', 'W/"2-d4cbb29"', - 'OK', 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/', 'Express', - 'sessionid=; Path=/,sessionid=6b059402-d62f-4e6f-b3dd-ce5b9e487c39; Path=/', - 'text/html; charset=utf-8', 'text/html; charset=utf-8', '9', 'OK', - 'sessionid=; Path=/', 'text/html; charset=utf-8', - 'text/html; charset=utf-8', '10', 'W/"a-eda64de5"', 'OK', 'Express', - 'Express', 'X-HTTP-Method-Override', 'sessionid=; Path=/', - 'application/json', - ], - - // Put it here so the benchmark result lines will not be super long. - LONG_AND_INVALID: ['Here is a value that is really a folded header ' + - 'value\r\n this should be supported, but it is not currently'] -}; - -const inputs = [ - // Valid - '', - '1', - '\t\t\t\t\t\t\t\t\t\tFoo bar baz', - 'keep-alive', - 'close', - 'gzip', - '20091', - 'private', - 'text/html; charset=utf-8', - 'text/plain', - 'Sat, 07 May 2016 16:54:48 GMT', - 'SAMEORIGIN', - 'en-US', - - // Invalid - '中文呢', // unicode - 'foo\nbar', - '\x7F', -]; - -const bench = common.createBenchmark(main, { - input: inputs.concat(Object.keys(groupedInputs)), - n: [1e6], -}); - -function main({ n, input }) { - let inputs = [input]; - if (groupedInputs.hasOwnProperty(input)) { - inputs = groupedInputs[input]; - } - - const len = inputs.length; - bench.start(); - for (var i = 0; i < n; i++) { - _checkInvalidHeaderChar(inputs[i % len]); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/check_is_http_token.js b/deps/node/benchmark/http/check_is_http_token.js deleted file mode 100644 index eab07524..00000000 --- a/deps/node/benchmark/http/check_is_http_token.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const _checkIsHttpToken = require('_http_common')._checkIsHttpToken; - -const bench = common.createBenchmark(main, { - key: [ - 'TCN', - 'ETag', - 'date', - 'Vary', - 'server', - 'Server', - 'status', - 'version', - 'Expires', - 'alt-svc', - 'location', - 'Connection', - 'Keep-Alive', - 'content-type', - 'Content-Type', - 'Cache-Control', - 'Last-Modified', - 'Accept-Ranges', - 'content-length', - 'x-frame-options', - 'x-xss-protection', - 'Content-Encoding', - 'Content-Location', - 'Transfer-Encoding', - 'alternate-protocol', - ':', // invalid input - '@@', - '中文呢', // unicode - '((((())))', // invalid - ':alternate-protocol', // fast bailout - 'alternate-protocol:', // slow bailout - ], - n: [1e6], -}); - -function main({ n, key }) { - bench.start(); - for (var i = 0; i < n; i++) { - _checkIsHttpToken(key); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/chunked.js b/deps/node/benchmark/http/chunked.js deleted file mode 100644 index 52b46057..00000000 --- a/deps/node/benchmark/http/chunked.js +++ /dev/null @@ -1,41 +0,0 @@ -// When calling .end(buffer) right away, this triggers a "hot path" -// optimization in http.js, to avoid an extra write call. -// -// However, the overhead of copying a large buffer is higher than -// the overhead of an extra write() call, so the hot path was not -// always as hot as it could be. -// -// Verify that our assumptions are valid. -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1, 4, 8, 16], - len: [1, 64, 256], - c: [100] -}); - -function main({ len, n, c }) { - const http = require('http'); - const chunk = Buffer.alloc(len, '8'); - - const server = http.createServer((req, res) => { - function send(left) { - if (left === 0) return res.end(); - res.write(chunk); - setTimeout(() => { - send(left - 1); - }, 0); - } - send(n); - }); - - server.listen(common.PORT, () => { - bench.http({ - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/client-request-body.js b/deps/node/benchmark/http/client-request-body.js deleted file mode 100644 index b5ac2828..00000000 --- a/deps/node/benchmark/http/client-request-body.js +++ /dev/null @@ -1,67 +0,0 @@ -// Measure the time it takes for the HTTP client to send a request body. -'use strict'; - -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - dur: [5], - type: ['asc', 'utf', 'buf'], - len: [32, 256, 1024], - method: ['write', 'end'] -}); - -function main({ dur, len, type, method }) { - var encoding; - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(len, 'x'); - break; - case 'utf': - encoding = 'utf8'; - chunk = 'ü'.repeat(len / 2); - break; - case 'asc': - chunk = 'a'.repeat(len); - break; - } - - var nreqs = 0; - const options = { - headers: { 'Connection': 'keep-alive', 'Transfer-Encoding': 'chunked' }, - agent: new http.Agent({ maxSockets: 1 }), - host: '127.0.0.1', - port: common.PORT, - path: '/', - method: 'POST' - }; - - const server = http.createServer((req, res) => { - res.end(); - }); - server.listen(options.port, options.host, () => { - setTimeout(done, dur * 1000); - bench.start(); - pummel(); - }); - - function pummel() { - const req = http.request(options, (res) => { - nreqs++; - pummel(); // Line up next request. - res.resume(); - }); - if (method === 'write') { - req.write(chunk, encoding); - req.end(); - } else { - req.end(chunk, encoding); - } - } - - function done() { - bench.end(nreqs); - process.exit(0); - } -} diff --git a/deps/node/benchmark/http/cluster.js b/deps/node/benchmark/http/cluster.js deleted file mode 100644 index 35d0ba98..00000000 --- a/deps/node/benchmark/http/cluster.js +++ /dev/null @@ -1,41 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const PORT = common.PORT; - -const cluster = require('cluster'); -if (cluster.isMaster) { - var bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - type: ['bytes', 'buffer'], - len: [4, 1024, 102400], - c: [50, 500] - }); -} else { - const port = parseInt(process.env.PORT || PORT); - require('../fixtures/simple-http-server.js').listen(port); -} - -function main({ type, len, c }) { - process.env.PORT = PORT; - var workers = 0; - const w1 = cluster.fork(); - const w2 = cluster.fork(); - - cluster.on('listening', () => { - workers++; - if (workers < 2) - return; - - setImmediate(() => { - const path = `/${type}/${len}`; - - bench.http({ - path: path, - connections: c - }, () => { - w1.destroy(); - w2.destroy(); - }); - }); - }); -} diff --git a/deps/node/benchmark/http/create-clientrequest.js b/deps/node/benchmark/http/create-clientrequest.js deleted file mode 100644 index 24d6e020..00000000 --- a/deps/node/benchmark/http/create-clientrequest.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { ClientRequest } = require('http'); -const assert = require('assert'); - -const types = Object.keys(common.urls) - .filter((i) => common.urls[i] - .startsWith('http://')); -const bench = common.createBenchmark(main, { - // Use 'url' to avoid name clash with other http benchmark - url: types.concat(['wpt']), - arg: ['URL', 'string', 'options'], - e: [1] -}); - -function noop() {} - -function main({ url: type, arg, e }) { - e = Number(e); - const data = common.bakeUrlData(type, e, false, false) - .filter((i) => i.startsWith('http://')); - const len = data.length; - let result; - switch (arg) { - case 'options': { - const options = data.map((i) => ({ - path: new URL(i).path, createConnection: noop - })); - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(options[i]); - } - bench.end(len); - break; - } - case 'URL': { - const options = data.map((i) => new URL(i)); - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(options[i], { createConnection: noop }); - } - bench.end(len); - break; - } - case 'string': { - bench.start(); - for (let i = 0; i < len; i++) { - result = new ClientRequest(data[i], { createConnection: noop }); - } - bench.end(len); - break; - } - default: { - throw new Error(`Unknown arg type ${arg}`); - } - } - assert.ok(result); -} diff --git a/deps/node/benchmark/http/end-vs-write-end.js b/deps/node/benchmark/http/end-vs-write-end.js deleted file mode 100644 index b4ca560b..00000000 --- a/deps/node/benchmark/http/end-vs-write-end.js +++ /dev/null @@ -1,57 +0,0 @@ -// When calling .end(buffer) right away, this triggers a "hot path" -// optimization in http.js, to avoid an extra write call. -// -// However, the overhead of copying a large buffer is higher than -// the overhead of an extra write() call, so the hot path was not -// always as hot as it could be. -// -// Verify that our assumptions are valid. -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - type: ['asc', 'utf', 'buf'], - len: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024], - c: [100], - method: ['write', 'end'] -}); - -function main({ len, type, method, c }) { - const http = require('http'); - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(len, 'x'); - break; - case 'utf': - chunk = 'ü'.repeat(len / 2); - break; - case 'asc': - chunk = 'a'.repeat(len); - break; - } - - function write(res) { - res.write(chunk); - res.end(); - } - - function end(res) { - res.end(chunk); - } - - const fn = method === 'write' ? write : end; - - const server = http.createServer((req, res) => { - fn(res); - }); - - server.listen(common.PORT, () => { - bench.http({ - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/headers.js b/deps/node/benchmark/http/headers.js deleted file mode 100644 index 8f611ae4..00000000 --- a/deps/node/benchmark/http/headers.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - n: [10, 1000], - len: [1, 100], -}); - -function main({ len, n }) { - const headers = { - 'Connection': 'keep-alive', - 'Transfer-Encoding': 'chunked', - }; - - const Is = [ ...Array(n / len).keys() ]; - const Js = [ ...Array(len).keys() ]; - for (const i of Is) { - headers[`foo${i}`] = Js.map(() => `some header value ${i}`); - } - - const server = http.createServer((req, res) => { - res.writeHead(200, headers); - res.end(); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - connections: 10 - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/http_server_for_chunky_client.js b/deps/node/benchmark/http/http_server_for_chunky_client.js deleted file mode 100644 index edcacf5d..00000000 --- a/deps/node/benchmark/http/http_server_for_chunky_client.js +++ /dev/null @@ -1,37 +0,0 @@ -'use strict'; - -const assert = require('assert'); -const http = require('http'); -const { fork } = require('child_process'); -const common = require('../common.js'); -const { PIPE } = require('../../test/common'); -const tmpdir = require('../../test/common/tmpdir'); -process.env.PIPE_NAME = PIPE; - -tmpdir.refresh(); - -var server; - -server = http.createServer((req, res) => { - const headers = { - 'content-type': 'text/plain', - 'content-length': '2' - }; - res.writeHead(200, headers); - res.end('ok'); -}); - -server.on('error', (err) => { - throw new Error(`server error: ${err}`); -}); -server.listen(PIPE); - -const child = fork( - `${__dirname}/_chunky_http_client.js`, - process.argv.slice(2) -); -child.on('message', common.sendResult); -child.on('close', (code) => { - server.close(); - assert.strictEqual(code, 0); -}); diff --git a/deps/node/benchmark/http/incoming_headers.js b/deps/node/benchmark/http/incoming_headers.js deleted file mode 100644 index 7d995576..00000000 --- a/deps/node/benchmark/http/incoming_headers.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const http = require('http'); - -const bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - c: [50, 500], - n: [0, 5, 20] -}); - -function main({ c, n }) { - const server = http.createServer((req, res) => { - res.end(); - }); - - server.listen(common.PORT, () => { - const headers = { - 'Content-Type': 'text/plain', - 'Accept': 'text/plain', - 'User-Agent': 'nodejs-benchmark', - 'Date': new Date().toString(), - 'Cache-Control': 'no-cache' - }; - for (let i = 0; i < n; i++) { - headers[`foo${i}`] = `some header value ${i}`; - } - bench.http({ - path: '/', - connections: c, - headers - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/set-header.js b/deps/node/benchmark/http/set-header.js deleted file mode 100644 index 01cd8492..00000000 --- a/deps/node/benchmark/http/set-header.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const PORT = common.PORT; - -const bench = common.createBenchmark(main, { - res: ['normal', 'setHeader', 'setHeaderWH'] -}); - -const type = 'bytes'; -const len = 4; -const chunks = 0; -const chunkedEnc = 0; -const c = 50; - -// normal: writeHead(status, {...}) -// setHeader: statusCode = status, setHeader(...) x2 -// setHeaderWH: setHeader(...), writeHead(status, ...) -function main({ res }) { - process.env.PORT = PORT; - var server = require('../fixtures/simple-http-server.js') - .listen(PORT) - .on('listening', () => { - const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`; - - bench.http({ - path: path, - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/set_header.js b/deps/node/benchmark/http/set_header.js deleted file mode 100644 index 4129e4fe..00000000 --- a/deps/node/benchmark/http/set_header.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const { OutgoingMessage } = require('_http_outgoing'); - -const bench = common.createBenchmark(main, { - value: [ - 'X-Powered-By', - 'Vary', - 'Set-Cookie', - 'Content-Type', - 'Content-Length', - 'Connection', - 'Transfer-Encoding', - ], - n: [1e6], -}); - -function main(conf) { - const n = +conf.n; - const value = conf.value; - - const og = new OutgoingMessage(); - - bench.start(); - for (var i = 0; i < n; i++) { - og.setHeader(value, ''); - } - bench.end(n); -} diff --git a/deps/node/benchmark/http/simple.js b/deps/node/benchmark/http/simple.js deleted file mode 100644 index c6faaaa9..00000000 --- a/deps/node/benchmark/http/simple.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - // unicode confuses ab on os x. - type: ['bytes', 'buffer'], - len: [4, 1024, 102400], - chunks: [1, 4], - c: [50, 500], - chunkedEnc: [1, 0] -}); - -function main({ type, len, chunks, c, chunkedEnc, res }) { - var server = require('../fixtures/simple-http-server.js') - .listen(common.PORT) - .on('listening', () => { - const path = `/${type}/${len}/${chunks}/normal/${chunkedEnc}`; - - bench.http({ - path: path, - connections: c - }, () => { - server.close(); - }); - }); -} diff --git a/deps/node/benchmark/http/upgrade.js b/deps/node/benchmark/http/upgrade.js deleted file mode 100644 index c286cdb2..00000000 --- a/deps/node/benchmark/http/upgrade.js +++ /dev/null @@ -1,51 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const net = require('net'); - -const bench = common.createBenchmark(main, { - n: [5, 1000] -}); - -const reqData = 'GET / HTTP/1.1\r\n' + - 'Upgrade: WebSocket\r\n' + - 'Connection: Upgrade\r\n' + - '\r\n' + - 'WjN}|M(6'; - -const resData = 'HTTP/1.1 101 Web Socket Protocol Handshake\r\n' + - 'Upgrade: WebSocket\r\n' + - 'Connection: Upgrade\r\n' + - '\r\n\r\n'; - -function main({ n }) { - var server = require('../fixtures/simple-http-server.js') - .listen(common.PORT) - .on('listening', () => { - bench.start(); - doBench(server.address(), n, () => { - bench.end(n); - server.close(); - }); - }) - .on('upgrade', (req, socket, upgradeHead) => { - socket.resume(); - socket.write(resData); - socket.end(); - }); -} - -function doBench(address, count, done) { - if (count === 0) { - done(); - return; - } - - const conn = net.createConnection(address.port); - conn.write(reqData); - conn.resume(); - - conn.on('end', () => { - doBench(address, count - 1, done); - }); -} diff --git a/deps/node/benchmark/http2/compat.js b/deps/node/benchmark/http2/compat.js deleted file mode 100644 index 5d06ccf3..00000000 --- a/deps/node/benchmark/http2/compat.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const path = require('path'); -const fs = require('fs'); -const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); - -const bench = common.createBenchmark(main, { - requests: [100, 1000, 5000], - streams: [1, 10, 20, 40, 100, 200], - clients: [2], - benchmarker: ['h2load'] -}, { flags: ['--no-warnings'] }); - -function main({ requests, streams, clients }) { - const http2 = require('http2'); - const server = http2.createServer(); - server.on('request', (req, res) => { - const out = fs.createReadStream(file); - res.setHeader('content-type', 'text/html'); - out.pipe(res); - out.on('error', (err) => { - res.destroy(); - }); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - requests, - maxConcurrentStreams: streams, - clients, - threads: clients - }, () => { server.close(); }); - }); -} diff --git a/deps/node/benchmark/http2/headers.js b/deps/node/benchmark/http2/headers.js deleted file mode 100644 index f18a73b9..00000000 --- a/deps/node/benchmark/http2/headers.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const PORT = common.PORT; - -const bench = common.createBenchmark(main, { - n: [1e3], - nheaders: [0, 10, 100, 1000] -}, { flags: ['--no-warnings'] }); - -function main({ n, nheaders }) { - const http2 = require('http2'); - const server = http2.createServer({ - maxHeaderListPairs: 20000 - }); - - const headersObject = { - ':path': '/', - ':scheme': 'http', - 'accept-encoding': 'gzip, deflate', - 'accept-language': 'en', - 'content-type': 'text/plain', - 'referer': 'https://example.org/', - 'user-agent': 'SuperBenchmarker 3000' - }; - - for (var i = 0; i < nheaders; i++) { - headersObject[`foo${i}`] = `some header value ${i}`; - } - - server.on('stream', (stream) => { - stream.respond(); - stream.end('Hi!'); - }); - server.listen(PORT, () => { - const client = http2.connect(`http://localhost:${PORT}/`, { - maxHeaderListPairs: 20000 - }); - - function doRequest(remaining) { - const req = client.request(headersObject); - req.resume(); - req.on('end', () => { - if (remaining > 0) { - doRequest(remaining - 1); - } else { - bench.end(n); - server.close(); - client.destroy(); - } - }); - } - - bench.start(); - doRequest(n); - }); -} diff --git a/deps/node/benchmark/http2/respond-with-fd.js b/deps/node/benchmark/http2/respond-with-fd.js deleted file mode 100644 index 35856490..00000000 --- a/deps/node/benchmark/http2/respond-with-fd.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const path = require('path'); -const fs = require('fs'); - -const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); - -const bench = common.createBenchmark(main, { - requests: [100, 1000, 5000], - streams: [1, 10, 20, 40, 100, 200], - clients: [2], - benchmarker: ['h2load'] -}, { flags: ['--no-warnings'] }); - -function main({ requests, streams, clients }) { - fs.open(file, 'r', (err, fd) => { - if (err) - throw err; - - const http2 = require('http2'); - const server = http2.createServer(); - server.on('stream', (stream) => { - stream.respondWithFD(fd); - stream.on('error', (err) => {}); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - requests, - maxConcurrentStreams: streams, - clients, - threads: clients - }, () => server.close()); - }); - - }); - -} diff --git a/deps/node/benchmark/http2/simple.js b/deps/node/benchmark/http2/simple.js deleted file mode 100644 index aab7c6b6..00000000 --- a/deps/node/benchmark/http2/simple.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const path = require('path'); -const fs = require('fs'); -const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); - -const bench = common.createBenchmark(main, { - requests: [100, 1000, 5000], - streams: [1, 10, 20, 40, 100, 200], - clients: [2], - benchmarker: ['h2load'] -}, { flags: ['--no-warnings'] }); - -function main({ requests, streams, clients }) { - const http2 = require('http2'); - const server = http2.createServer(); - server.on('stream', (stream) => { - const out = fs.createReadStream(file); - stream.respond(); - out.pipe(stream); - stream.on('error', (err) => {}); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - requests, - maxConcurrentStreams: streams, - clients, - threads: clients - }, () => { server.close(); }); - }); -} diff --git a/deps/node/benchmark/http2/write.js b/deps/node/benchmark/http2/write.js deleted file mode 100644 index fc3203c6..00000000 --- a/deps/node/benchmark/http2/write.js +++ /dev/null @@ -1,35 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - streams: [100, 200, 1000], - length: [64 * 1024, 128 * 1024, 256 * 1024, 1024 * 1024], - size: [100000], - benchmarker: ['h2load'] -}, { flags: ['--no-warnings'] }); - -function main({ streams, length, size }) { - const http2 = require('http2'); - const server = http2.createServer(); - server.on('stream', (stream) => { - stream.respond(); - let written = 0; - function write() { - stream.write('ü'.repeat(size)); - written += size; - if (written < length) - setImmediate(write); - else - stream.end(); - } - write(); - }); - server.listen(common.PORT, () => { - bench.http({ - path: '/', - requests: 10000, - maxConcurrentStreams: streams, - }, () => { server.close(); }); - }); -} diff --git a/deps/node/benchmark/misc/arguments.js b/deps/node/benchmark/misc/arguments.js deleted file mode 100644 index 5b0cb0e2..00000000 --- a/deps/node/benchmark/misc/arguments.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -const { createBenchmark } = require('../common.js'); -const { format } = require('util'); - -const methods = [ - 'restAndSpread', - 'argumentsAndApply', - 'restAndApply', - 'predefined', -]; - -const bench = createBenchmark(main, { - method: methods, - n: [1e6] -}); - -function usingRestAndSpread(...args) { - format(...args); -} - -function usingRestAndApply(...args) { - format.apply(null, args); -} - -function usingArgumentsAndApply() { - format.apply(null, arguments); -} - -function usingPredefined() { - format('part 1', 'part', 2, 'part 3', 'part', 4); -} - -function main({ n, method, args }) { - var fn; - switch (method) { - // '' is a default case for tests - case '': - case 'restAndSpread': - fn = usingRestAndSpread; - break; - case 'restAndApply': - fn = usingRestAndApply; - break; - case 'argumentsAndApply': - fn = usingArgumentsAndApply; - break; - case 'predefined': - fn = usingPredefined; - break; - default: - throw new Error(`Unexpected method "${method}"`); - } - - bench.start(); - for (var i = 0; i < n; i++) - fn('part 1', 'part', 2, 'part 3', 'part', 4); - bench.end(n); -} diff --git a/deps/node/benchmark/misc/freelist.js b/deps/node/benchmark/misc/freelist.js deleted file mode 100644 index 7fa9af4f..00000000 --- a/deps/node/benchmark/misc/freelist.js +++ /dev/null @@ -1,38 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [100000] -}, { - flags: ['--expose-internals'] -}); - -function main({ n }) { - const { FreeList } = require('internal/freelist'); - const poolSize = 1000; - const list = new FreeList('test', poolSize, Object); - var j; - const used = []; - - // First, alloc `poolSize` items - for (j = 0; j < poolSize; j++) { - used.push(list.alloc()); - } - - bench.start(); - - for (var i = 0; i < n; i++) { - // Return all the items to the pool - for (j = 0; j < poolSize; j++) { - list.free(used[j]); - } - - // Re-alloc from pool - for (j = 0; j < poolSize; j++) { - list.alloc(); - } - } - - bench.end(n); -} diff --git a/deps/node/benchmark/misc/object-property-bench.js b/deps/node/benchmark/misc/object-property-bench.js deleted file mode 100644 index fae11119..00000000 --- a/deps/node/benchmark/misc/object-property-bench.js +++ /dev/null @@ -1,84 +0,0 @@ -'use strict'; - -/* eslint-disable dot-notation */ - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - method: ['property', 'string', 'variable', 'symbol'], - n: [1e9] -}); - -function runProperty(n) { - const object = {}; - var i = 0; - bench.start(); - for (; i < n; i++) { - object.p1 = 21; - object.p2 = 21; - object.p1 += object.p2; - } - bench.end(n); -} - -function runString(n) { - const object = {}; - var i = 0; - bench.start(); - for (; i < n; i++) { - object['p1'] = 21; - object['p2'] = 21; - object['p1'] += object['p2']; - } - bench.end(n); -} - -function runVariable(n) { - const object = {}; - const var1 = 'p1'; - const var2 = 'p2'; - var i = 0; - bench.start(); - for (; i < n; i++) { - object[var1] = 21; - object[var2] = 21; - object[var1] += object[var2]; - } - bench.end(n); -} - -function runSymbol(n) { - const object = {}; - const symbol1 = Symbol('p1'); - const symbol2 = Symbol('p2'); - var i = 0; - bench.start(); - for (; i < n; i++) { - object[symbol1] = 21; - object[symbol2] = 21; - object[symbol1] += object[symbol2]; - } - bench.end(n); -} - -function main({ n, method }) { - - switch (method) { - // '' is a default case for tests - case '': - case 'property': - runProperty(n); - break; - case 'string': - runString(n); - break; - case 'variable': - runVariable(n); - break; - case 'symbol': - runSymbol(n); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/misc/punycode.js b/deps/node/benchmark/misc/punycode.js deleted file mode 100644 index 18023419..00000000 --- a/deps/node/benchmark/misc/punycode.js +++ /dev/null @@ -1,80 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -let icu; -try { - icu = common.binding('icu'); -} catch {} -const punycode = require('punycode'); - -const bench = common.createBenchmark(main, { - method: ['punycode'].concat(icu !== undefined ? ['icu'] : []), - n: [1024], - val: [ - 'افغانستا.icom.museum', - 'الجزائر.icom.museum', - 'österreich.icom.museum', - 'বাংলাদেশ.icom.museum', - 'беларусь.icom.museum', - 'belgië.icom.museum', - 'българия.icom.museum', - 'تشادر.icom.museum', - '中国.icom.museum', - 'القمر.icom.museum', - 'κυπρος.icom.museum', - 'českárepublika.icom.museum', - 'مصر.icom.museum', - 'ελλάδα.icom.museum', - 'magyarország.icom.museum', - 'ísland.icom.museum', - 'भारत.icom.museum', - 'ايران.icom.museum', - 'éire.icom.museum', - 'איקו״ם.ישראל.museum', - '日本.icom.museum', - 'الأردن.icom.museum', - ] -}); - -function usingPunycode(val) { - punycode.toUnicode(punycode.toASCII(val)); -} - -function usingICU(val) { - icu.toUnicode(icu.toASCII(val)); -} - -function runPunycode(n, val) { - var i = 0; - for (; i < n; i++) - usingPunycode(val); - bench.start(); - for (i = 0; i < n; i++) - usingPunycode(val); - bench.end(n); -} - -function runICU(n, val) { - bench.start(); - for (var i = 0; i < n; i++) - usingICU(val); - bench.end(n); -} - -function main({ n, val, method }) { - switch (method) { - // '' is a default case for tests - case '': - case 'punycode': - runPunycode(n, val); - break; - case 'icu': - if (icu !== undefined) { - runICU(n, val); - break; - } - // fallthrough - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/misc/startup.js b/deps/node/benchmark/misc/startup.js deleted file mode 100644 index da24ee65..00000000 --- a/deps/node/benchmark/misc/startup.js +++ /dev/null @@ -1,76 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { spawn } = require('child_process'); -const path = require('path'); - -let Worker; // Lazy loaded in main - -const bench = common.createBenchmark(main, { - dur: [1], - script: ['benchmark/fixtures/require-cachable', 'test/fixtures/semicolon'], - mode: ['process', 'worker'] -}, { - flags: ['--expose-internals'] -}); - -function spawnProcess(script) { - const cmd = process.execPath || process.argv[0]; - const argv = ['--expose-internals', script]; - return spawn(cmd, argv); -} - -function spawnWorker(script) { - return new Worker(script, { stderr: true, stdout: true }); -} - -function start(state, script, bench, getNode) { - const node = getNode(script); - let stdout = ''; - let stderr = ''; - - node.stdout.on('data', (data) => { - stdout += data; - }); - - node.stderr.on('data', (data) => { - stderr += data; - }); - - node.on('exit', (code) => { - if (code !== 0) { - console.error('------ stdout ------'); - console.error(stdout); - console.error('------ stderr ------'); - console.error(stderr); - throw new Error(`Error during node startup, exit code ${code}`); - } - state.throughput++; - - if (state.go) { - start(state, script, bench, getNode); - } else { - bench.end(state.throughput); - } - }); -} - -function main({ dur, script, mode }) { - const state = { - go: true, - throughput: 0 - }; - - setTimeout(() => { - state.go = false; - }, dur * 1000); - - script = path.resolve(__dirname, '../../', `${script}.js`); - if (mode === 'worker') { - Worker = require('worker_threads').Worker; - bench.start(); - start(state, script, bench, spawnWorker); - } else { - bench.start(); - start(state, script, bench, spawnProcess); - } -} diff --git a/deps/node/benchmark/misc/trace.js b/deps/node/benchmark/misc/trace.js deleted file mode 100644 index d76f53cf..00000000 --- a/deps/node/benchmark/misc/trace.js +++ /dev/null @@ -1,50 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [100000], - method: ['trace', 'isTraceCategoryEnabled'] -}, { - flags: ['--expose-internals', '--trace-event-categories', 'foo'] -}); - -const { - TRACE_EVENT_PHASE_NESTABLE_ASYNC_BEGIN: kBeforeEvent -} = common.binding('constants').trace; - -function doTrace(n, trace) { - bench.start(); - for (var i = 0; i < n; i++) { - trace(kBeforeEvent, 'foo', 'test', 0, 'test'); - } - bench.end(n); -} - -function doIsTraceCategoryEnabled(n, isTraceCategoryEnabled) { - bench.start(); - for (var i = 0; i < n; i++) { - isTraceCategoryEnabled('foo'); - isTraceCategoryEnabled('bar'); - } - bench.end(n); -} - -function main({ n, method }) { - const { - trace, - isTraceCategoryEnabled - } = common.binding('trace_events'); - - switch (method) { - case '': - case 'trace': - doTrace(n, trace); - break; - case 'isTraceCategoryEnabled': - doIsTraceCategoryEnabled(n, isTraceCategoryEnabled); - break; - default: - throw new Error(`Unexpected method "${method}"`); - } -} diff --git a/deps/node/benchmark/misc/util-extend-vs-object-assign.js b/deps/node/benchmark/misc/util-extend-vs-object-assign.js deleted file mode 100644 index 3880711b..00000000 --- a/deps/node/benchmark/misc/util-extend-vs-object-assign.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const util = require('util'); - -const bench = common.createBenchmark(main, { - type: ['extend', 'assign'], - n: [10e4] -}); - -function main({ n, type }) { - // Default value for tests. - if (type === '') - type = 'extend'; - - let fn; - if (type === 'extend') { - fn = util._extend; - } else if (type === 'assign') { - fn = Object.assign; - } - - // Force-optimize the method to test so that the benchmark doesn't - // get disrupted by the optimizer kicking in halfway through. - for (var i = 0; i < type.length * 10; i += 1) - fn({}, process.env); - - const obj = new Proxy({}, { set: function(a, b, c) { return true; } }); - - bench.start(); - for (var j = 0; j < n; j += 1) - fn(obj, process.env); - bench.end(n); -} diff --git a/deps/node/benchmark/module/module-loader.js b/deps/node/benchmark/module/module-loader.js deleted file mode 100644 index e780d637..00000000 --- a/deps/node/benchmark/module/module-loader.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; -const fs = require('fs'); -const path = require('path'); -const common = require('../common.js'); - -const tmpdir = require('../../test/common/tmpdir'); -const benchmarkDirectory = path.join(tmpdir.path, 'nodejs-benchmark-module'); - -const bench = common.createBenchmark(main, { - n: [5e4], - fullPath: ['true', 'false'], - useCache: ['true', 'false'] -}); - -function main({ n, fullPath, useCache }) { - tmpdir.refresh(); - try { fs.mkdirSync(benchmarkDirectory); } catch {} - for (var i = 0; i <= n; i++) { - fs.mkdirSync(`${benchmarkDirectory}${i}`); - fs.writeFileSync( - `${benchmarkDirectory}${i}/package.json`, - '{"main": "index.js"}' - ); - fs.writeFileSync( - `${benchmarkDirectory}${i}/index.js`, - 'module.exports = "";' - ); - } - - if (fullPath === 'true') - measureFull(n, useCache === 'true'); - else - measureDir(n, useCache === 'true'); - - tmpdir.refresh(); -} - -function measureFull(n, useCache) { - var i; - if (useCache) { - for (i = 0; i <= n; i++) { - require(`${benchmarkDirectory}${i}/index.js`); - } - } - bench.start(); - for (i = 0; i <= n; i++) { - require(`${benchmarkDirectory}${i}/index.js`); - } - bench.end(n); -} - -function measureDir(n, useCache) { - var i; - if (useCache) { - for (i = 0; i <= n; i++) { - require(`${benchmarkDirectory}${i}`); - } - } - bench.start(); - for (i = 0; i <= n; i++) { - require(`${benchmarkDirectory}${i}`); - } - bench.end(n); -} diff --git a/deps/node/benchmark/napi/function_args/.gitignore b/deps/node/benchmark/napi/function_args/.gitignore deleted file mode 100644 index 567609b1..00000000 --- a/deps/node/benchmark/napi/function_args/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/deps/node/benchmark/napi/function_args/binding.cc b/deps/node/benchmark/napi/function_args/binding.cc deleted file mode 100644 index 9f250aaa..00000000 --- a/deps/node/benchmark/napi/function_args/binding.cc +++ /dev/null @@ -1,143 +0,0 @@ -#include <v8.h> -#include <node.h> -#include <assert.h> - -using v8::Isolate; -using v8::Context; -using v8::Local; -using v8::MaybeLocal; -using v8::Value; -using v8::Number; -using v8::String; -using v8::Object; -using v8::Array; -using v8::ArrayBufferView; -using v8::ArrayBuffer; -using v8::FunctionCallbackInfo; - -void CallWithString(const FunctionCallbackInfo<Value>& args) { - assert(args.Length() == 1 && args[0]->IsString()); - if (args.Length() == 1 && args[0]->IsString()) { - Local<String> str = args[0].As<String>(); - const int32_t length = str->Utf8Length(args.GetIsolate()) + 1; - char* buf = new char[length]; - str->WriteUtf8(args.GetIsolate(), buf, length); - delete [] buf; - } -} - -void CallWithArray(const FunctionCallbackInfo<Value>& args) { - assert(args.Length() == 1 && args[0]->IsArray()); - if (args.Length() == 1 && args[0]->IsArray()) { - const Local<Array> array = args[0].As<Array>(); - uint32_t length = array->Length(); - for (uint32_t i = 0; i < length; ++ i) { - Local<Value> v; - v = array->Get(args.GetIsolate()->GetCurrentContext(), - i).ToLocalChecked(); - } - } -} - -void CallWithNumber(const FunctionCallbackInfo<Value>& args) { - assert(args.Length() == 1 && args[0]->IsNumber()); - if (args.Length() == 1 && args[0]->IsNumber()) { - args[0].As<Number>()->Value(); - } -} - -void CallWithObject(const FunctionCallbackInfo<Value>& args) { - Isolate* isolate = args.GetIsolate(); - Local<Context> context = isolate->GetCurrentContext(); - - assert(args.Length() == 1 && args[0]->IsObject()); - if (args.Length() == 1 && args[0]->IsObject()) { - Local<Object> obj = args[0].As<Object>(); - - MaybeLocal<String> map_key = String::NewFromUtf8(isolate, - "map", v8::NewStringType::kNormal); - assert(!map_key.IsEmpty()); - MaybeLocal<Value> map_maybe = obj->Get(context, - map_key.ToLocalChecked()); - assert(!map_maybe.IsEmpty()); - Local<Value> map; - map = map_maybe.ToLocalChecked(); - - MaybeLocal<String> operand_key = String::NewFromUtf8(isolate, - "operand", v8::NewStringType::kNormal); - assert(!operand_key.IsEmpty()); - MaybeLocal<Value> operand_maybe = obj->Get(context, - operand_key.ToLocalChecked()); - assert(!operand_maybe.IsEmpty()); - Local<Value> operand; - operand = operand_maybe.ToLocalChecked(); - - MaybeLocal<String> data_key = String::NewFromUtf8(isolate, - "data", v8::NewStringType::kNormal); - assert(!data_key.IsEmpty()); - MaybeLocal<Value> data_maybe = obj->Get(context, - data_key.ToLocalChecked()); - assert(!data_maybe.IsEmpty()); - Local<Value> data; - data = data_maybe.ToLocalChecked(); - - MaybeLocal<String> reduce_key = String::NewFromUtf8(isolate, - "reduce", v8::NewStringType::kNormal); - assert(!reduce_key.IsEmpty()); - MaybeLocal<Value> reduce_maybe = obj->Get(context, - reduce_key.ToLocalChecked()); - assert(!reduce_maybe.IsEmpty()); - Local<Value> reduce; - reduce = reduce_maybe.ToLocalChecked(); - } -} - -void CallWithTypedarray(const FunctionCallbackInfo<Value>& args) { - assert(args.Length() == 1 && args[0]->IsArrayBufferView()); - if (args.Length() == 1 && args[0]->IsArrayBufferView()) { - assert(args[0]->IsArrayBufferView()); - Local<ArrayBufferView> view = args[0].As<ArrayBufferView>(); - const size_t byte_offset = view->ByteOffset(); - const size_t byte_length = view->ByteLength(); - assert(byte_length > 0); - assert(view->HasBuffer()); - Local<ArrayBuffer> buffer; - buffer = view->Buffer(); - ArrayBuffer::Contents contents; - contents = buffer->GetContents(); - const uint32_t* data = reinterpret_cast<uint32_t*>( - static_cast<uint8_t*>(contents.Data()) + byte_offset); - assert(data); - } -} - -void CallWithArguments(const FunctionCallbackInfo<Value>& args) { - assert(args.Length() > 1 && args[0]->IsNumber()); - if (args.Length() > 1 && args[0]->IsNumber()) { - int32_t loop = args[0].As<v8::Uint32>()->Value(); - for (int32_t i = 1; i < loop; ++i) { - assert(i < args.Length()); - assert(args[i]->IsUint32()); - args[i].As<v8::Uint32>()->Value(); - } - } -} - -void Initialize(Local<Object> target) { - NODE_SET_METHOD(target, "callWithString", CallWithString); - NODE_SET_METHOD(target, "callWithLongString", CallWithString); - - NODE_SET_METHOD(target, "callWithArray", CallWithArray); - NODE_SET_METHOD(target, "callWithLargeArray", CallWithArray); - NODE_SET_METHOD(target, "callWithHugeArray", CallWithArray); - - NODE_SET_METHOD(target, "callWithNumber", CallWithNumber); - NODE_SET_METHOD(target, "callWithObject", CallWithObject); - NODE_SET_METHOD(target, "callWithTypedarray", CallWithTypedarray); - - NODE_SET_METHOD(target, "callWith10Numbers", CallWithArguments); - NODE_SET_METHOD(target, "callWith100Numbers", CallWithArguments); - NODE_SET_METHOD(target, "callWith1000Numbers", CallWithArguments); -} - -NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) diff --git a/deps/node/benchmark/napi/function_args/binding.gyp b/deps/node/benchmark/napi/function_args/binding.gyp deleted file mode 100644 index ac122ed1..00000000 --- a/deps/node/benchmark/napi/function_args/binding.gyp +++ /dev/null @@ -1,12 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'napi_binding', - 'sources': [ 'napi_binding.c' ] - }, - { - 'target_name': 'binding', - 'sources': [ 'binding.cc' ] - } - ] -} diff --git a/deps/node/benchmark/napi/function_args/index.js b/deps/node/benchmark/napi/function_args/index.js deleted file mode 100644 index 8f134549..00000000 --- a/deps/node/benchmark/napi/function_args/index.js +++ /dev/null @@ -1,97 +0,0 @@ -// Show the difference between calling a V8 binding C++ function -// relative to a comparable N-API C++ function, -// in various types/numbers of arguments. -// Reports n of calls per second. -'use strict'; - -const common = require('../../common.js'); - -let v8; -let napi; - -try { - v8 = require(`./build/${common.buildType}/binding`); -} catch { - console.error(`${__filename}: V8 Binding failed to load`); - process.exit(0); -} - -try { - napi = require(`./build/${common.buildType}/napi_binding`); -} catch { - console.error(`${__filename}: NAPI-Binding failed to load`); - process.exit(0); -} - -const argsTypes = ['String', 'Number', 'Object', 'Array', 'Typedarray', - '10Numbers', '100Numbers', '1000Numbers']; - -const generateArgs = (argType) => { - let args = []; - - if (argType === 'String') { - args.push('The quick brown fox jumps over the lazy dog'); - } else if (argType === 'LongString') { - args.push(Buffer.alloc(32768, '42').toString()); - } else if (argType === 'Number') { - args.push(Math.floor(314158964 * Math.random())); - } else if (argType === 'Object') { - args.push({ - map: 'add', - operand: 10, - data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10], - reduce: 'add', - }); - } else if (argType === 'Array') { - const arr = []; - for (let i = 0; i < 50; ++i) { - arr.push(Math.random() * 10e9); - } - args.push(arr); - } else if (argType === 'Typedarray') { - const arr = new Uint32Array(1000); - for (let i = 0; i < 1000; ++i) { - arr[i] = Math.random() * 4294967296; - } - args.push(arr); - } else if (argType === '10Numbers') { - args.push(10); - for (let i = 0; i < 9; ++i) { - args = [...args, ...generateArgs('Number')]; - } - } else if (argType === '100Numbers') { - args.push(100); - for (let i = 0; i < 99; ++i) { - args = [...args, ...generateArgs('Number')]; - } - } else if (argType === '1000Numbers') { - args.push(1000); - for (let i = 0; i < 999; ++i) { - args = [...args, ...generateArgs('Number')]; - } - } - - return args; -}; - -const bench = common.createBenchmark(main, { - type: argsTypes, - engine: ['v8', 'napi'], - n: [1, 1e1, 1e2, 1e3, 1e4, 1e5], -}); - -function main({ n, engine, type }) { - const bindings = engine === 'v8' ? v8 : napi; - const methodName = 'callWith' + type; - const fn = bindings[methodName]; - - if (fn) { - const args = generateArgs(type); - - bench.start(); - for (var i = 0; i < n; i++) { - fn.apply(null, args); - } - bench.end(n); - } -} diff --git a/deps/node/benchmark/napi/function_args/napi_binding.c b/deps/node/benchmark/napi/function_args/napi_binding.c deleted file mode 100644 index 1a3a0f1c..00000000 --- a/deps/node/benchmark/napi/function_args/napi_binding.c +++ /dev/null @@ -1,231 +0,0 @@ -#include <node_api.h> -#include <assert.h> -#include <stdlib.h> -#include <stdio.h> -#include <string.h> - -static napi_value CallWithString(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1]; - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - - napi_valuetype types[1]; - status = napi_typeof(env, args[0], types); - assert(status == napi_ok); - - assert(types[0] == napi_string); - if (types[0] == napi_string) { - size_t len = 0; - // Get the length - status = napi_get_value_string_utf8(env, args[0], NULL, 0, &len); - assert(status == napi_ok); - char* buf = (char*)malloc(len + 1); - status = napi_get_value_string_utf8(env, args[0], buf, len + 1, &len); - assert(status == napi_ok); - free(buf); - } - - return NULL; -} - -static napi_value CallWithArray(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1]; - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - - napi_value array = args[0]; - bool is_array = false; - status = napi_is_array(env, array, &is_array); - assert(status == napi_ok); - - assert(is_array); - if (is_array) { - uint32_t length; - status = napi_get_array_length(env, array, &length); - assert(status == napi_ok); - - uint32_t i; - for (i = 0; i < length; ++i) { - napi_value v; - status = napi_get_element(env, array, i, &v); - assert(status == napi_ok); - } - } - - return NULL; -} - -static napi_value CallWithNumber(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1]; - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - - napi_valuetype types[1]; - status = napi_typeof(env, args[0], types); - assert(status == napi_ok); - - assert(types[0] == napi_number); - if (types[0] == napi_number) { - double value = 0.0; - status = napi_get_value_double(env, args[0], &value); - assert(status == napi_ok); - } - - return NULL; -} - -static napi_value CallWithObject(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1]; - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - - napi_valuetype types[1]; - status = napi_typeof(env, args[0], types); - assert(status == napi_ok); - - assert(argc == 1 && types[0] == napi_object); - if (argc == 1 && types[0] == napi_object) { - napi_value value; - - status = napi_get_named_property(env, args[0], "map", &value); - assert(status == napi_ok); - - status = napi_get_named_property(env, args[0], "operand", &value); - assert(status == napi_ok); - - status = napi_get_named_property(env, args[0], "data", &value); - assert(status == napi_ok); - - status = napi_get_named_property(env, args[0], "reduce", &value); - assert(status == napi_ok); - } - - return NULL; -} - -static napi_value CallWithTypedarray(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1]; - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - - bool is_typedarray = false; - status = napi_is_typedarray(env, args[0], &is_typedarray); - assert(status == napi_ok); - - assert(is_typedarray); - if (is_typedarray) { - napi_typedarray_type type; - napi_value input_buffer; - size_t byte_offset = 0; - size_t length = 0; - status = napi_get_typedarray_info(env, args[0], &type, &length, - NULL, &input_buffer, &byte_offset); - assert(status == napi_ok); - assert(length > 0); - - void* data = NULL; - size_t byte_length = 0; - status = napi_get_arraybuffer_info(env, - input_buffer, &data, &byte_length); - assert(status == napi_ok); - - uint32_t* input_integers = (uint32_t*)((uint8_t*)(data) + byte_offset); - assert(input_integers); - } - - return NULL; -} - -static napi_value CallWithArguments(napi_env env, napi_callback_info info) { - napi_status status; - - size_t argc = 1; - napi_value args[1000]; - // Get the length - status = napi_get_cb_info(env, info, &argc, NULL, NULL, NULL); - assert(status == napi_ok); - - status = napi_get_cb_info(env, info, &argc, args, NULL, NULL); - assert(status == napi_ok); - assert(argc <= 1000); - - napi_valuetype types[1]; - status = napi_typeof(env, args[0], types); - assert(status == napi_ok); - - assert(argc > 1 && types[0] == napi_number); - if (argc > 1 && types[0] == napi_number) { - uint32_t loop = 0; - status = napi_get_value_uint32(env, args[0], &loop); - assert(status == napi_ok); - - uint32_t i; - for (i = 1; i < loop; ++i) { - assert(i < argc); - status = napi_typeof(env, args[i], types); - assert(status == napi_ok); - assert(types[0] == napi_number); - - uint32_t value = 0; - status = napi_get_value_uint32(env, args[i], &value); - assert(status == napi_ok); - } - } - - return NULL; -} - - -#define EXPORT_FUNC(env, exports, name, func) \ - do { \ - napi_status status; \ - napi_value js_func; \ - status = napi_create_function((env), \ - (name), \ - NAPI_AUTO_LENGTH, \ - (func), \ - NULL, \ - &js_func); \ - assert(status == napi_ok); \ - status = napi_set_named_property((env), \ - (exports), \ - (name), \ - js_func); \ - assert(status == napi_ok); \ - } while (0); - - -NAPI_MODULE_INIT() { - EXPORT_FUNC(env, exports, "callWithString", CallWithString); - EXPORT_FUNC(env, exports, "callWithLongString", CallWithString); - - EXPORT_FUNC(env, exports, "callWithArray", CallWithArray); - EXPORT_FUNC(env, exports, "callWithLargeArray", CallWithArray); - EXPORT_FUNC(env, exports, "callWithHugeArray", CallWithArray); - - EXPORT_FUNC(env, exports, "callWithNumber", CallWithNumber); - - EXPORT_FUNC(env, exports, "callWithObject", CallWithObject); - EXPORT_FUNC(env, exports, "callWithTypedarray", CallWithTypedarray); - - EXPORT_FUNC(env, exports, "callWith10Numbers", CallWithArguments); - EXPORT_FUNC(env, exports, "callWith100Numbers", CallWithArguments); - EXPORT_FUNC(env, exports, "callWith1000Numbers", CallWithArguments); - - return exports; -} diff --git a/deps/node/benchmark/napi/function_call/.gitignore b/deps/node/benchmark/napi/function_call/.gitignore deleted file mode 100644 index 567609b1..00000000 --- a/deps/node/benchmark/napi/function_call/.gitignore +++ /dev/null @@ -1 +0,0 @@ -build/ diff --git a/deps/node/benchmark/napi/function_call/binding.cc b/deps/node/benchmark/napi/function_call/binding.cc deleted file mode 100644 index 289a94ac..00000000 --- a/deps/node/benchmark/napi/function_call/binding.cc +++ /dev/null @@ -1,14 +0,0 @@ -#include <v8.h> -#include <node.h> - -static int c = 0; - -void Hello(const v8::FunctionCallbackInfo<v8::Value>& args) { - args.GetReturnValue().Set(c++); -} - -void Initialize(v8::Local<v8::Object> target) { - NODE_SET_METHOD(target, "hello", Hello); -} - -NODE_MODULE(NODE_GYP_MODULE_NAME, Initialize) diff --git a/deps/node/benchmark/napi/function_call/binding.gyp b/deps/node/benchmark/napi/function_call/binding.gyp deleted file mode 100644 index ac122ed1..00000000 --- a/deps/node/benchmark/napi/function_call/binding.gyp +++ /dev/null @@ -1,12 +0,0 @@ -{ - 'targets': [ - { - 'target_name': 'napi_binding', - 'sources': [ 'napi_binding.c' ] - }, - { - 'target_name': 'binding', - 'sources': [ 'binding.cc' ] - } - ] -} diff --git a/deps/node/benchmark/napi/function_call/index.js b/deps/node/benchmark/napi/function_call/index.js deleted file mode 100644 index b63d805f..00000000 --- a/deps/node/benchmark/napi/function_call/index.js +++ /dev/null @@ -1,50 +0,0 @@ -// Show the difference between calling a short js function -// relative to a comparable C++ function. -// Reports n of calls per second. -// Note that JS speed goes up, while cxx speed stays about the same. -'use strict'; - -const assert = require('assert'); -const common = require('../../common.js'); - -// This fails when we try to open with a different version of node, -// which is quite common for benchmarks. so in that case, just -// abort quietly. - -try { - var binding = require(`./build/${common.buildType}/binding`); -} catch { - console.error('misc/function_call.js Binding failed to load'); - process.exit(0); -} -const cxx = binding.hello; - -let napi_binding; -try { - napi_binding = require(`./build/${common.buildType}/napi_binding`); -} catch { - console.error('misc/function_call/index.js NAPI-Binding failed to load'); - process.exit(0); -} -const napi = napi_binding.hello; - -var c = 0; -function js() { - return c++; -} - -assert(js() === cxx()); - -const bench = common.createBenchmark(main, { - type: ['js', 'cxx', 'napi'], - n: [1e6, 1e7, 5e7] -}); - -function main({ n, type }) { - const fn = type === 'cxx' ? cxx : type === 'napi' ? napi : js; - bench.start(); - for (var i = 0; i < n; i++) { - fn(); - } - bench.end(n); -} diff --git a/deps/node/benchmark/napi/function_call/napi_binding.c b/deps/node/benchmark/napi/function_call/napi_binding.c deleted file mode 100644 index d97170e0..00000000 --- a/deps/node/benchmark/napi/function_call/napi_binding.c +++ /dev/null @@ -1,26 +0,0 @@ -#include <assert.h> -#include <node_api.h> - -static int32_t increment = 0; - -static napi_value Hello(napi_env env, napi_callback_info info) { - napi_value result; - napi_status status = napi_create_int32(env, increment++, &result); - assert(status == napi_ok); - return result; -} - -NAPI_MODULE_INIT() { - napi_value hello; - napi_status status = - napi_create_function(env, - "hello", - NAPI_AUTO_LENGTH, - Hello, - NULL, - &hello); - assert(status == napi_ok); - status = napi_set_named_property(env, exports, "hello", hello); - assert(status == napi_ok); - return exports; -} 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); - }; - } -} diff --git a/deps/node/benchmark/os/cpus.js b/deps/node/benchmark/os/cpus.js deleted file mode 100644 index da158a1b..00000000 --- a/deps/node/benchmark/os/cpus.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const cpus = require('os').cpus; - -const bench = common.createBenchmark(main, { - n: [3e4] -}); - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; ++i) - cpus(); - bench.end(n); -} diff --git a/deps/node/benchmark/os/loadavg.js b/deps/node/benchmark/os/loadavg.js deleted file mode 100644 index 2cd38316..00000000 --- a/deps/node/benchmark/os/loadavg.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const loadavg = require('os').loadavg; - -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; ++i) - loadavg(); - bench.end(n); -} diff --git a/deps/node/benchmark/os/networkInterfaces.js b/deps/node/benchmark/os/networkInterfaces.js deleted file mode 100644 index 3fa6073a..00000000 --- a/deps/node/benchmark/os/networkInterfaces.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const networkInterfaces = require('os').networkInterfaces; - -const bench = common.createBenchmark(main, { - n: [1e4] -}); - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; ++i) - networkInterfaces(); - bench.end(n); -} diff --git a/deps/node/benchmark/path/basename-posix.js b/deps/node/benchmark/path/basename-posix.js deleted file mode 100644 index 45cad1e2..00000000 --- a/deps/node/benchmark/path/basename-posix.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - pathext: [ - '', - '/', - '/foo', - '/foo/.bar.baz', - ['/foo/.bar.baz', '.baz'].join('|'), - 'foo', - 'foo/bar.', - ['foo/bar.', '.'].join('|'), - '/foo/bar/baz/asdf/quux.html', - ['/foo/bar/baz/asdf/quux.html', '.html'].join('|'), - ], - n: [1e5] -}); - -function main({ n, pathext }) { - var ext; - const extIdx = pathext.indexOf('|'); - if (extIdx !== -1) { - ext = pathext.slice(extIdx + 1); - pathext = pathext.slice(0, extIdx); - } - - bench.start(); - for (var i = 0; i < n; i++) { - posix.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/basename-win32.js b/deps/node/benchmark/path/basename-win32.js deleted file mode 100644 index 30d65f3a..00000000 --- a/deps/node/benchmark/path/basename-win32.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - pathext: [ - '', - 'C:\\', - 'C:\\foo', - 'D:\\foo\\.bar.baz', - ['E:\\foo\\.bar.baz', '.baz'].join('|'), - 'foo', - 'foo\\bar.', - ['foo\\bar.', '.'].join('|'), - '\\foo\\bar\\baz\\asdf\\quux.html', - ['\\foo\\bar\\baz\\asdf\\quux.html', '.html'].join('|'), - ], - n: [1e5] -}); - -function main({ n, pathext }) { - var ext; - const extIdx = pathext.indexOf('|'); - if (extIdx !== -1) { - ext = pathext.slice(extIdx + 1); - pathext = pathext.slice(0, extIdx); - } - - bench.start(); - for (var i = 0; i < n; i++) { - win32.basename(i % 3 === 0 ? `${pathext}${i}` : pathext, ext); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/dirname-posix.js b/deps/node/benchmark/path/dirname-posix.js deleted file mode 100644 index 93f2f32c..00000000 --- a/deps/node/benchmark/path/dirname-posix.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '/', - '/foo', - '/foo/bar', - 'foo', - 'foo/bar', - '/foo/bar/baz/asdf/quux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - posix.dirname(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/dirname-win32.js b/deps/node/benchmark/path/dirname-win32.js deleted file mode 100644 index 510595d7..00000000 --- a/deps/node/benchmark/path/dirname-win32.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '\\', - '\\foo', - 'C:\\foo\\bar', - 'foo', - 'foo\\bar', - 'D:\\foo\\bar\\baz\\asdf\\quux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - win32.dirname(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/extname-posix.js b/deps/node/benchmark/path/extname-posix.js deleted file mode 100644 index ee1ea07e..00000000 --- a/deps/node/benchmark/path/extname-posix.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '/', - '/foo', - 'foo/.bar.baz', - 'index.html', - 'index', - 'foo/bar/..baz.quux', - 'foo/bar/...baz.quux', - '/foo/bar/baz/asdf/quux', - '/foo/bar/baz/asdf/quux.foobarbazasdfquux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - posix.extname(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/extname-win32.js b/deps/node/benchmark/path/extname-win32.js deleted file mode 100644 index 1de4bca2..00000000 --- a/deps/node/benchmark/path/extname-win32.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '\\', - 'C:\\foo', - 'foo\\.bar.baz', - 'index.html', - 'index', - 'foo\\bar\\..baz.quux', - 'foo\\bar\\...baz.quux', - 'D:\\foo\\bar\\baz\\asdf\\quux', - '\\foo\\bar\\baz\\asdf\\quux.foobarbazasdfquux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - win32.extname(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/format-posix.js b/deps/node/benchmark/path/format-posix.js deleted file mode 100644 index 9c555f23..00000000 --- a/deps/node/benchmark/path/format-posix.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - props: [ - ['/', '/home/user/dir', 'index.html', '.html', 'index'].join('|'), - ], - n: [1e6] -}); - -function main({ n, props }) { - props = props.split('|'); - const obj = { - root: props[0] || '', - dir: props[1] || '', - base: '', - ext: props[3] || '', - name: '', - }; - - bench.start(); - for (var i = 0; i < n; i++) { - obj.base = `a${i}${props[2] || ''}`; - obj.name = `a${i}${props[4] || ''}`; - posix.format(obj); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/format-win32.js b/deps/node/benchmark/path/format-win32.js deleted file mode 100644 index 65315c4d..00000000 --- a/deps/node/benchmark/path/format-win32.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - props: [ - ['C:\\', 'C:\\path\\dir', 'index.html', '.html', 'index'].join('|'), - ], - n: [1e6] -}); - -function main({ n, props }) { - props = props.split('|'); - const obj = { - root: props[0] || '', - dir: props[1] || '', - base: '', - ext: props[3] || '', - name: '', - }; - - bench.start(); - for (var i = 0; i < n; i++) { - obj.base = `a${i}${props[2] || ''}`; - obj.name = `a${i}${props[4] || ''}`; - win32.format(obj); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/isAbsolute-posix.js b/deps/node/benchmark/path/isAbsolute-posix.js deleted file mode 100644 index dd0dfd19..00000000 --- a/deps/node/benchmark/path/isAbsolute-posix.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '.', - '/foo/bar', - '/baz/..', - 'bar/baz', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - posix.isAbsolute(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/isAbsolute-win32.js b/deps/node/benchmark/path/isAbsolute-win32.js deleted file mode 100644 index ff03f262..00000000 --- a/deps/node/benchmark/path/isAbsolute-win32.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '.', - '//server', - 'C:\\baz\\..', - 'C:baz\\..', - 'bar\\baz', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - win32.isAbsolute(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/join-posix.js b/deps/node/benchmark/path/join-posix.js deleted file mode 100644 index e573166d..00000000 --- a/deps/node/benchmark/path/join-posix.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - ['/foo', 'bar', '', 'baz/asdf', 'quux', '..'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - const args = paths.split('|'); - const copy = [...args]; - const orig = copy[1]; - - bench.start(); - for (var i = 0; i < n; i++) { - if (i % 3 === 0) { - copy[1] = `${orig}${i}`; - posix.join(...copy); - } else { - posix.join(...args); - } - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/join-win32.js b/deps/node/benchmark/path/join-win32.js deleted file mode 100644 index cd69836c..00000000 --- a/deps/node/benchmark/path/join-win32.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - ['C:\\foo', 'bar', '', 'baz\\asdf', 'quux', '..'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - const args = paths.split('|'); - const copy = [...args]; - const orig = copy[1]; - - bench.start(); - for (var i = 0; i < n; i++) { - if (i % 3 === 0) { - copy[1] = `${orig}${i}`; - win32.join(...copy); - } else { - win32.join(...args); - } - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/makeLong-win32.js b/deps/node/benchmark/path/makeLong-win32.js deleted file mode 100644 index 45d0d8de..00000000 --- a/deps/node/benchmark/path/makeLong-win32.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - 'foo\\bar', - 'C:\\foo', - '\\\\foo\\bar', - '\\\\?\\foo', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - win32._makeLong(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/normalize-posix.js b/deps/node/benchmark/path/normalize-posix.js deleted file mode 100644 index 4383cff4..00000000 --- a/deps/node/benchmark/path/normalize-posix.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '.', - '/../', - '/foo', - '/foo/bar', - '/foo/bar//baz/asdf/quux/..', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - posix.normalize(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/normalize-win32.js b/deps/node/benchmark/path/normalize-win32.js deleted file mode 100644 index 319c391d..00000000 --- a/deps/node/benchmark/path/normalize-win32.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '.', - 'C:\\..\\', - 'C:\\foo', - 'C:\\foo\\bar', - 'C:\\foo\\bar\\\\baz\\asdf\\quux\\..', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (var i = 0; i < n; i++) { - win32.normalize(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/parse-posix.js b/deps/node/benchmark/path/parse-posix.js deleted file mode 100644 index 7fb1d550..00000000 --- a/deps/node/benchmark/path/parse-posix.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - '/', - '/foo', - '/foo/bar.baz', - 'foo/.bar.baz', - 'foo/bar', - '/foo/bar/baz/asdf/.quux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (let i = 0; i < n; i++) { - posix.parse(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/parse-win32.js b/deps/node/benchmark/path/parse-win32.js deleted file mode 100644 index ea4bc34a..00000000 --- a/deps/node/benchmark/path/parse-win32.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - path: [ - '', - 'C:\\', - 'C:\\foo', - '\\foo', - 'E:\\foo\\bar.baz', - 'foo\\.bar.baz', - 'foo\\bar', - '\\foo\\bar\\baz\\asdf\\.quux', - ], - n: [1e5] -}); - -function main({ n, path }) { - bench.start(); - for (let i = 0; i < n; i++) { - win32.parse(i % 3 === 0 ? `${path}${i}` : path); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/relative-posix.js b/deps/node/benchmark/path/relative-posix.js deleted file mode 100644 index 2c4dd31d..00000000 --- a/deps/node/benchmark/path/relative-posix.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - ['/data/orandea/test/aaa', '/data/orandea/impl/bbb'].join('|'), - ['/', '/var'].join('|'), - ['/', '/'].join('|'), - ['/var', '/bin'].join('|'), - ['/foo/bar/baz/quux', '/'].join('|'), - ['/foo/bar/baz/quux', '/foo/bar/baz/quux'].join('|'), - ['/foo/bar/baz/quux', '/var/log'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - var to = ''; - const delimIdx = paths.indexOf('|'); - if (delimIdx > -1) { - to = paths.slice(delimIdx + 1); - paths = paths.slice(0, delimIdx); - } - - bench.start(); - for (let i = 0; i < n; i++) { - if (i % 3 === 0) - posix.relative(`${paths}${i}`, `${to}${i}`); - else - posix.relative(paths, to); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/relative-win32.js b/deps/node/benchmark/path/relative-win32.js deleted file mode 100644 index 5f34fdf8..00000000 --- a/deps/node/benchmark/path/relative-win32.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - ['C:\\orandea\\test\\aaa', 'C:\\orandea\\impl\\bbb'].join('|'), - ['C:\\', 'D:\\'].join('|'), - ['C:\\foo\\bar\\baz', 'C:\\foo\\bar\\baz'].join('|'), - ['C:\\foo\\BAR\\BAZ', 'C:\\foo\\bar\\baz'].join('|'), - ['C:\\foo\\bar\\baz\\quux', 'C:\\'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - var to = ''; - const delimIdx = paths.indexOf('|'); - if (delimIdx > -1) { - to = paths.slice(delimIdx + 1); - paths = paths.slice(0, delimIdx); - } - - bench.start(); - for (let i = 0; i < n; i++) { - if (i % 3 === 0) - win32.relative(`${paths}${i}`, `${to}${i}`); - else - win32.relative(paths, to); - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/resolve-posix.js b/deps/node/benchmark/path/resolve-posix.js deleted file mode 100644 index 3cdf1cd4..00000000 --- a/deps/node/benchmark/path/resolve-posix.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { posix } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - '', - ['', ''].join('|'), - ['foo/bar', '/tmp/file/', '..', 'a/../subfile'].join('|'), - ['a/b/c/', '../../..'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - const args = paths.split('|'); - const copy = [...args]; - const orig = copy[0]; - - bench.start(); - for (var i = 0; i < n; i++) { - if (i % 3 === 0) { - copy[0] = `${orig}${i}`; - posix.resolve(...copy); - } else { - posix.resolve(...args); - } - } - bench.end(n); -} diff --git a/deps/node/benchmark/path/resolve-win32.js b/deps/node/benchmark/path/resolve-win32.js deleted file mode 100644 index cf8144ef..00000000 --- a/deps/node/benchmark/path/resolve-win32.js +++ /dev/null @@ -1,30 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { win32 } = require('path'); - -const bench = common.createBenchmark(main, { - paths: [ - '', - ['', ''].join('|'), - ['c:/ignore', 'd:\\a/b\\c/d', '\\e.exe'].join('|'), - ['c:/blah\\blah', 'd:/games', 'c:../a'].join('|'), - ], - n: [1e5] -}); - -function main({ n, paths }) { - const args = paths.split('|'); - const copy = [...args]; - const orig = copy[0]; - - bench.start(); - for (var i = 0; i < n; i++) { - if (i % 3 === 0) { - copy[0] = `${orig}${i}`; - win32.resolve(...copy); - } else { - win32.resolve(...args); - } - } - bench.end(n); -} diff --git a/deps/node/benchmark/process/bench-env.js b/deps/node/benchmark/process/bench-env.js deleted file mode 100644 index a332d3cb..00000000 --- a/deps/node/benchmark/process/bench-env.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const bench = common.createBenchmark(main, { - n: [1e5], -}); - - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; i++) { - // Access every item in object to process values. - Object.keys(process.env); - } - bench.end(n); -} diff --git a/deps/node/benchmark/process/bench-hrtime.js b/deps/node/benchmark/process/bench-hrtime.js deleted file mode 100644 index e704087b..00000000 --- a/deps/node/benchmark/process/bench-hrtime.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; - -const common = require('../common'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [1e6], - type: ['raw', 'diff', 'bigint'] -}); - -function main({ n, type }) { - const hrtime = process.hrtime; - var noDead = type === 'bigint' ? hrtime.bigint() : hrtime(); - var i; - - switch (type) { - case 'raw': - bench.start(); - for (i = 0; i < n; i++) { - noDead = hrtime(); - } - bench.end(n); - break; - case 'diff': - bench.start(); - for (i = 0; i < n; i++) { - noDead = hrtime(noDead); - } - bench.end(n); - break; - case 'bigint': - bench.start(); - for (i = 0; i < n; i++) { - noDead = hrtime.bigint(); - } - bench.end(n); - break; - } - - // eslint-disable-next-line valid-typeof - assert.ok(Array.isArray(noDead) || typeof noDead === 'bigint'); -} diff --git a/deps/node/benchmark/process/memoryUsage.js b/deps/node/benchmark/process/memoryUsage.js deleted file mode 100644 index f9b969ab..00000000 --- a/deps/node/benchmark/process/memoryUsage.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [1e5] -}); - -function main({ n }) { - bench.start(); - for (var i = 0; i < n; i++) { - process.memoryUsage(); - } - bench.end(n); -} diff --git a/deps/node/benchmark/process/next-tick-breadth-args.js b/deps/node/benchmark/process/next-tick-breadth-args.js deleted file mode 100644 index 6baa8d99..00000000 --- a/deps/node/benchmark/process/next-tick-breadth-args.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [4e6] -}); - -function main({ n }) { - var j = 0; - - function cb1(arg1) { - j++; - if (j === n) - bench.end(n); - } - function cb2(arg1, arg2) { - j++; - if (j === n) - bench.end(n); - } - function cb3(arg1, arg2, arg3) { - j++; - if (j === n) - bench.end(n); - } - function cb4(arg1, arg2, arg3, arg4) { - j++; - if (j === n) - bench.end(n); - } - - bench.start(); - for (var i = 0; i < n; i++) { - if (i % 4 === 0) - process.nextTick(cb4, 3.14, 1024, true, false); - else if (i % 3 === 0) - process.nextTick(cb3, 512, true, null); - else if (i % 2 === 0) - process.nextTick(cb2, false, 5.1); - else - process.nextTick(cb1, 0); - } -} diff --git a/deps/node/benchmark/process/next-tick-breadth.js b/deps/node/benchmark/process/next-tick-breadth.js deleted file mode 100644 index 392d8e02..00000000 --- a/deps/node/benchmark/process/next-tick-breadth.js +++ /dev/null @@ -1,21 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [4e6] -}); - -function main({ n }) { - var j = 0; - - function cb() { - j++; - if (j === n) - bench.end(n); - } - - bench.start(); - for (var i = 0; i < n; i++) { - process.nextTick(cb); - } -} diff --git a/deps/node/benchmark/process/next-tick-depth-args.js b/deps/node/benchmark/process/next-tick-depth-args.js deleted file mode 100644 index da61f90a..00000000 --- a/deps/node/benchmark/process/next-tick-depth-args.js +++ /dev/null @@ -1,64 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [12e6] -}); - -function main({ n }) { - let counter = n; - function cb4(arg1, arg2, arg3, arg4) { - if (--counter) { - if (counter % 4 === 0) - process.nextTick(cb4, 3.14, 1024, true, false); - else if (counter % 3 === 0) - process.nextTick(cb3, 512, true, null); - else if (counter % 2 === 0) - process.nextTick(cb2, false, 5.1); - else - process.nextTick(cb1, 0); - } else - bench.end(n); - } - function cb3(arg1, arg2, arg3) { - if (--counter) { - if (counter % 4 === 0) - process.nextTick(cb4, 3.14, 1024, true, false); - else if (counter % 3 === 0) - process.nextTick(cb3, 512, true, null); - else if (counter % 2 === 0) - process.nextTick(cb2, false, 5.1); - else - process.nextTick(cb1, 0); - } else - bench.end(n); - } - function cb2(arg1, arg2) { - if (--counter) { - if (counter % 4 === 0) - process.nextTick(cb4, 3.14, 1024, true, false); - else if (counter % 3 === 0) - process.nextTick(cb3, 512, true, null); - else if (counter % 2 === 0) - process.nextTick(cb2, false, 5.1); - else - process.nextTick(cb1, 0); - } else - bench.end(n); - } - function cb1(arg1) { - if (--counter) { - if (counter % 4 === 0) - process.nextTick(cb4, 3.14, 1024, true, false); - else if (counter % 3 === 0) - process.nextTick(cb3, 512, true, null); - else if (counter % 2 === 0) - process.nextTick(cb2, false, 5.1); - else - process.nextTick(cb1, 0); - } else - bench.end(n); - } - bench.start(); - process.nextTick(cb1, true); -} diff --git a/deps/node/benchmark/process/next-tick-depth.js b/deps/node/benchmark/process/next-tick-depth.js deleted file mode 100644 index c88e042b..00000000 --- a/deps/node/benchmark/process/next-tick-depth.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [12e6] -}); - -function main({ n }) { - let counter = n; - bench.start(); - process.nextTick(onNextTick); - function onNextTick() { - if (--counter) - process.nextTick(onNextTick); - else - bench.end(n); - } -} diff --git a/deps/node/benchmark/process/next-tick-exec-args.js b/deps/node/benchmark/process/next-tick-exec-args.js deleted file mode 100644 index f5d0fb94..00000000 --- a/deps/node/benchmark/process/next-tick-exec-args.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - function onNextTick(i) { - if (i + 1 === n) - bench.end(n); - } - - for (var i = 0; i < n; i++) { - if (i % 4 === 0) - process.nextTick(onNextTick, i, true, 10, 'test'); - else if (i % 3 === 0) - process.nextTick(onNextTick, i, true, 10); - else if (i % 2 === 0) - process.nextTick(onNextTick, i, 20); - else - process.nextTick(onNextTick, i); - } - - bench.start(); -} diff --git a/deps/node/benchmark/process/next-tick-exec.js b/deps/node/benchmark/process/next-tick-exec.js deleted file mode 100644 index 936b253b..00000000 --- a/deps/node/benchmark/process/next-tick-exec.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - function onNextTick(i) { - if (i + 1 === n) - bench.end(n); - } - - for (var i = 0; i < n; i++) { - process.nextTick(onNextTick, i); - } - - bench.start(); -} diff --git a/deps/node/benchmark/querystring/querystring-parse.js b/deps/node/benchmark/querystring/querystring-parse.js deleted file mode 100644 index ca4dca13..00000000 --- a/deps/node/benchmark/querystring/querystring-parse.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const querystring = require('querystring'); -const inputs = common.searchParams; - -const bench = common.createBenchmark(main, { - type: Object.keys(inputs), - n: [1e6], -}); - -function main({ type, n }) { - const input = inputs[type]; - var i; - // Execute the function a "sufficient" number of times before the timed - // loop to ensure the function is optimized just once. - if (type === 'multicharsep') { - for (i = 0; i < n; i += 1) - querystring.parse(input, '&&&&&&&&&&'); - - bench.start(); - for (i = 0; i < n; i += 1) - querystring.parse(input, '&&&&&&&&&&'); - bench.end(n); - } else { - for (i = 0; i < n; i += 1) - querystring.parse(input); - - bench.start(); - for (i = 0; i < n; i += 1) - querystring.parse(input); - bench.end(n); - } -} diff --git a/deps/node/benchmark/querystring/querystring-stringify.js b/deps/node/benchmark/querystring/querystring-stringify.js deleted file mode 100644 index 9f025c92..00000000 --- a/deps/node/benchmark/querystring/querystring-stringify.js +++ /dev/null @@ -1,39 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const querystring = require('querystring'); - -const bench = common.createBenchmark(main, { - type: ['noencode', 'encodemany', 'encodelast'], - n: [1e7], -}); - -function main({ type, n }) { - const inputs = { - noencode: { - foo: 'bar', - baz: 'quux', - xyzzy: 'thud' - }, - encodemany: { - '\u0080\u0083\u0089': 'bar', - '\u008C\u008E\u0099': 'quux', - 'xyzzy': '\u00A5q\u00A3r' - }, - encodelast: { - foo: 'bar', - baz: 'quux', - xyzzy: 'thu\u00AC' - } - }; - const input = inputs[type]; - - // Force-optimize querystring.stringify() so that the benchmark doesn't get - // disrupted by the optimizer kicking in halfway through. - for (const name in inputs) - querystring.stringify(inputs[name]); - - bench.start(); - for (var i = 0; i < n; i += 1) - querystring.stringify(input); - bench.end(n); -} diff --git a/deps/node/benchmark/querystring/querystring-unescapebuffer.js b/deps/node/benchmark/querystring/querystring-unescapebuffer.js deleted file mode 100644 index 39dd085e..00000000 --- a/deps/node/benchmark/querystring/querystring-unescapebuffer.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const querystring = require('querystring'); - -const bench = common.createBenchmark(main, { - input: [ - 'there is nothing to unescape here', - 'there%20are%20several%20spaces%20that%20need%20to%20be%20unescaped', - 'there%2Qare%0-fake%escaped values in%%%%this%9Hstring', - '%20%21%22%23%24%25%26%27%28%29%2A%2B%2C%2D%2E%2F%30%31%32%33%34%35%36%37', - ], - n: [10e6], -}); - -function main({ input, n }) { - bench.start(); - for (var i = 0; i < n; i += 1) - querystring.unescapeBuffer(input); - bench.end(n); -} diff --git a/deps/node/benchmark/run.js b/deps/node/benchmark/run.js deleted file mode 100644 index 2eb1ab1a..00000000 --- a/deps/node/benchmark/run.js +++ /dev/null @@ -1,77 +0,0 @@ -'use strict'; - -const path = require('path'); -const fork = require('child_process').fork; -const CLI = require('./_cli.js'); - -const cli = CLI(`usage: ./node run.js [options] [--] <category> ... - Run each benchmark in the <category> directory a single time, more than one - <category> directory can be specified. - - --filter pattern string to filter benchmark scripts - --set variable=value set benchmark variable (can be repeated) - --format [simple|csv] optional value that specifies the output format -`, { arrayArgs: ['set'] }); -const benchmarks = cli.benchmarks(); - -if (benchmarks.length === 0) { - console.error('No benchmarks found'); - process.exitCode = 1; - return; -} - -const validFormats = ['csv', 'simple']; -const format = cli.optional.format || 'simple'; -if (!validFormats.includes(format)) { - console.error('Invalid format detected'); - process.exitCode = 1; - return; -} - -if (format === 'csv') { - console.log('"filename", "configuration", "rate", "time"'); -} - -(function recursive(i) { - const filename = benchmarks[i]; - const child = fork(path.resolve(__dirname, filename), cli.optional.set); - - if (format !== 'csv') { - console.log(); - console.log(filename); - } - - child.on('message', (data) => { - if (data.type !== 'report') { - return; - } - // Construct configuration string, " A=a, B=b, ..." - let conf = ''; - for (const key of Object.keys(data.conf)) { - conf += ` ${key}=${JSON.stringify(data.conf[key])}`; - } - // Delete first space of the configuration - conf = conf.slice(1); - if (format === 'csv') { - // Escape quotes (") for correct csv formatting - conf = conf.replace(/"/g, '""'); - console.log(`"${data.name}", "${conf}", ${data.rate}, ${data.time}`); - } else { - var rate = data.rate.toString().split('.'); - rate[0] = rate[0].replace(/(\d)(?=(?:\d\d\d)+(?!\d))/g, '$1,'); - rate = (rate[1] ? rate.join('.') : rate[0]); - console.log(`${data.name} ${conf}: ${rate}`); - } - }); - - child.once('close', (code) => { - if (code) { - process.exit(code); - } - - // If there are more benchmarks execute the next - if (i + 1 < benchmarks.length) { - recursive(i + 1); - } - }); -})(0); diff --git a/deps/node/benchmark/scatter.R b/deps/node/benchmark/scatter.R deleted file mode 100644 index 1574987a..00000000 --- a/deps/node/benchmark/scatter.R +++ /dev/null @@ -1,86 +0,0 @@ -#!/usr/bin/env Rscript -library(ggplot2); -library(plyr); - -# get __dirname and load ./_cli.R -args = commandArgs(trailingOnly = F); -dirname = dirname(sub("--file=", "", args[grep("--file", args)])); -source(paste0(dirname, '/_cli.R'), chdir=T); - -if (is.null(args.options$xaxis) || is.null(args.options$category) || - (!is.null(args.options$plot) && args.options$plot == TRUE)) { - stop("usage: cat file.csv | Rscript scatter.R [variable=value ...] - --xaxis variable variable name to use as xaxis (required) - --category variable variable name to use as colored category (required) - --plot filename save plot to filename - --log use a log-2 scale for xaxis in the plot"); -} - -plot.filename = args.options$plot; - -# parse options -x.axis.name = args.options$xaxis; -category.name = args.options$category; -use.log2 = !is.null(args.options$log); - -# parse data -dat = read.csv(file('stdin'), strip.white=TRUE); -dat = data.frame(dat); - -# List of aggregated variables -aggregate = names(dat); -aggregate = aggregate[ - ! aggregate %in% c('rate', 'time', 'filename', x.axis.name, category.name) -]; -# Variables that don't change aren't aggregated -for (aggregate.key in aggregate) { - if (length(unique(dat[[aggregate.key]])) == 1) { - aggregate = aggregate[aggregate != aggregate.key]; - } -} - -# Print out aggregated variables -for (aggregate.variable in aggregate) { - cat(sprintf('aggregating variable: %s\n', aggregate.variable)); -} -if (length(aggregate) > 0) { - cat('\n'); -} - -# Calculate statistics -stats = ddply(dat, c(x.axis.name, category.name), function(subdat) { - rate = subdat$rate; - - # calculate confidence interval of the mean - ci = NA; - if (length(rate) > 1) { - se = sqrt(var(rate)/length(rate)); - ci = se * qt(0.975, length(rate) - 1) - } - - # calculate mean and 95 % confidence interval - r = list( - rate = mean(rate), - confidence.interval = ci - ); - - return(data.frame(r)); -}); - -print(stats, row.names=F); - -if (!is.null(plot.filename)) { - p = ggplot(stats, aes_string(x=x.axis.name, y='rate', colour=category.name)); - if (use.log2) { - p = p + scale_x_continuous(trans='log2'); - } - p = p + geom_errorbar( - aes(ymin=rate-confidence.interval, ymax=rate+confidence.interval), - width=.1, na.rm=TRUE - ); - p = p + geom_point(); - p = p + geom_line(); - p = p + ylab("rate of operations (higher is better)"); - p = p + ggtitle(dat[1, 1]); - ggsave(plot.filename, p); -} diff --git a/deps/node/benchmark/scatter.js b/deps/node/benchmark/scatter.js deleted file mode 100644 index 10649e6b..00000000 --- a/deps/node/benchmark/scatter.js +++ /dev/null @@ -1,74 +0,0 @@ -'use strict'; - -const fork = require('child_process').fork; -const path = require('path'); -const CLI = require('./_cli.js'); - -// -// Parse arguments -// -const cli = CLI(`usage: ./node scatter.js [options] [--] <filename> - Run the benchmark script <filename> many times and output the rate (ops/s) - together with the benchmark variables as a csv. - - --runs 30 number of samples - --set variable=value set benchmark variable (can be repeated) -`, { arrayArgs: ['set'] }); - -if (cli.items.length !== 1) { - cli.abort(cli.usage); -} - -// Create queue from the benchmarks list such both node versions are tested -// `runs` amount of times each. -const filepath = path.resolve(cli.items[0]); -const name = filepath.slice(__dirname.length + 1); -const runs = cli.optional.runs ? parseInt(cli.optional.runs, 10) : 30; - -let printHeader = true; - -function csvEncodeValue(value) { - if (typeof value === 'number') { - return value.toString(); - } else { - return `"${value.replace(/"/g, '""')}"`; - } -} - -(function recursive(i) { - const child = fork(path.resolve(__dirname, filepath), cli.optional.set); - - child.on('message', (data) => { - if (data.type !== 'report') { - return; - } - - // print csv header - if (printHeader) { - const confHeader = Object.keys(data.conf) - .map(csvEncodeValue) - .join(', '); - console.log(`"filename", ${confHeader}, "rate", "time"`); - printHeader = false; - } - - // print data row - const confData = Object.keys(data.conf) - .map((key) => csvEncodeValue(data.conf[key])) - .join(', '); - - console.log(`"${name}", ${confData}, ${data.rate}, ${data.time}`); - }); - - child.once('close', (code) => { - if (code) { - process.exit(code); - return; - } - - // If there are more benchmarks execute the next - if (i + 1 < runs) { - recursive(i + 1); - } - }); -})(0); diff --git a/deps/node/benchmark/streams/creation.js b/deps/node/benchmark/streams/creation.js deleted file mode 100644 index 46a0a547..00000000 --- a/deps/node/benchmark/streams/creation.js +++ /dev/null @@ -1,57 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { - Duplex, - Readable, - Transform, - Writable, -} = require('stream'); - -const bench = common.createBenchmark(main, { - n: [50e6], - kind: ['duplex', 'readable', 'transform', 'writable'] -}); - -function main({ n, kind }) { - var i = 0; - switch (kind) { - case 'duplex': - new Duplex({}); - new Duplex(); - - bench.start(); - for (; i < n; ++i) - new Duplex(); - bench.end(n); - break; - case 'readable': - new Readable({}); - new Readable(); - - bench.start(); - for (; i < n; ++i) - new Readable(); - bench.end(n); - break; - case 'writable': - new Writable({}); - new Writable(); - - bench.start(); - for (; i < n; ++i) - new Writable(); - bench.end(n); - break; - case 'transform': - new Transform({}); - new Transform(); - - bench.start(); - for (; i < n; ++i) - new Transform(); - bench.end(n); - break; - default: - throw new Error('Invalid kind'); - } -} diff --git a/deps/node/benchmark/streams/pipe-object-mode.js b/deps/node/benchmark/streams/pipe-object-mode.js deleted file mode 100644 index d52b2238..00000000 --- a/deps/node/benchmark/streams/pipe-object-mode.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -const { Readable, Writable } = require('stream'); - -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - const b = {}; - const r = new Readable({ objectMode: true }); - const w = new Writable({ objectMode: true }); - - var i = 0; - - r._read = () => r.push(i++ === n ? null : b); - w._write = (data, enc, cb) => cb(); - - bench.start(); - - r.pipe(w); - w.on('finish', () => bench.end(n)); -} diff --git a/deps/node/benchmark/streams/pipe.js b/deps/node/benchmark/streams/pipe.js deleted file mode 100644 index 4baeeb2d..00000000 --- a/deps/node/benchmark/streams/pipe.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common'); -const { Readable, Writable } = require('stream'); - -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - const b = Buffer.alloc(1024); - const r = new Readable(); - const w = new Writable(); - - var i = 0; - - r._read = () => r.push(i++ === n ? null : b); - w._write = (data, enc, cb) => cb(); - - bench.start(); - - r.pipe(w); - w.on('finish', () => bench.end(n)); -} diff --git a/deps/node/benchmark/streams/readable-bigread.js b/deps/node/benchmark/streams/readable-bigread.js deleted file mode 100644 index c3cff3d9..00000000 --- a/deps/node/benchmark/streams/readable-bigread.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Readable = require('stream').Readable; - -const bench = common.createBenchmark(main, { - n: [1e3] -}); - -function main({ n }) { - const b = Buffer.alloc(32); - const s = new Readable(); - function noop() {} - s._read = noop; - - bench.start(); - for (var k = 0; k < n; ++k) { - for (var i = 0; i < 1e4; ++i) - s.push(b); - while (s.read(128)); - } - bench.end(n); -} diff --git a/deps/node/benchmark/streams/readable-bigunevenread.js b/deps/node/benchmark/streams/readable-bigunevenread.js deleted file mode 100644 index 95a4139c..00000000 --- a/deps/node/benchmark/streams/readable-bigunevenread.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Readable = require('stream').Readable; - -const bench = common.createBenchmark(main, { - n: [1e3] -}); - -function main({ n }) { - const b = Buffer.alloc(32); - const s = new Readable(); - function noop() {} - s._read = noop; - - bench.start(); - for (var k = 0; k < n; ++k) { - for (var i = 0; i < 1e4; ++i) - s.push(b); - while (s.read(106)); - } - bench.end(n); -} diff --git a/deps/node/benchmark/streams/readable-boundaryread.js b/deps/node/benchmark/streams/readable-boundaryread.js deleted file mode 100644 index 835c7d18..00000000 --- a/deps/node/benchmark/streams/readable-boundaryread.js +++ /dev/null @@ -1,25 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Readable = require('stream').Readable; - -const bench = common.createBenchmark(main, { - n: [200e1], - type: ['string', 'buffer'] -}); - -function main({ n, type }) { - const s = new Readable(); - var data = 'a'.repeat(32); - if (type === 'buffer') - data = Buffer.from(data); - s._read = function() {}; - - bench.start(); - for (var k = 0; k < n; ++k) { - for (var i = 0; i < 1e4; ++i) - s.push(data); - while (s.read(32)); - } - bench.end(n); -} diff --git a/deps/node/benchmark/streams/readable-readall.js b/deps/node/benchmark/streams/readable-readall.js deleted file mode 100644 index 3c177ec4..00000000 --- a/deps/node/benchmark/streams/readable-readall.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Readable = require('stream').Readable; - -const bench = common.createBenchmark(main, { - n: [50e2] -}); - -function main({ n }) { - const b = Buffer.alloc(32); - const s = new Readable(); - function noop() {} - s._read = noop; - - bench.start(); - for (var k = 0; k < n; ++k) { - for (var i = 0; i < 1e4; ++i) - s.push(b); - while (s.read()); - } - bench.end(n); -} diff --git a/deps/node/benchmark/streams/readable-unevenread.js b/deps/node/benchmark/streams/readable-unevenread.js deleted file mode 100644 index 690f1f42..00000000 --- a/deps/node/benchmark/streams/readable-unevenread.js +++ /dev/null @@ -1,23 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Readable = require('stream').Readable; - -const bench = common.createBenchmark(main, { - n: [1e3] -}); - -function main({ n }) { - const b = Buffer.alloc(32); - const s = new Readable(); - function noop() {} - s._read = noop; - - bench.start(); - for (var k = 0; k < n; ++k) { - for (var i = 0; i < 1e4; ++i) - s.push(b); - while (s.read(12)); - } - bench.end(n); -} diff --git a/deps/node/benchmark/streams/writable-manywrites.js b/deps/node/benchmark/streams/writable-manywrites.js deleted file mode 100644 index 6fcb07e8..00000000 --- a/deps/node/benchmark/streams/writable-manywrites.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const common = require('../common'); -const Writable = require('stream').Writable; - -const bench = common.createBenchmark(main, { - n: [2e6] -}); - -function main({ n }) { - const b = Buffer.allocUnsafe(1024); - const s = new Writable(); - s._write = function(chunk, encoding, cb) { - cb(); - }; - - bench.start(); - for (var k = 0; k < n; ++k) { - s.write(b); - } - bench.end(n); -} diff --git a/deps/node/benchmark/string_decoder/string-decoder-create.js b/deps/node/benchmark/string_decoder/string-decoder-create.js deleted file mode 100644 index fad72722..00000000 --- a/deps/node/benchmark/string_decoder/string-decoder-create.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const StringDecoder = require('string_decoder').StringDecoder; - -const bench = common.createBenchmark(main, { - encoding: [ - 'ascii', 'utf8', 'utf-8', 'base64', 'ucs2', 'UTF-8', 'AscII', 'UTF-16LE', - ], - n: [25e6] -}); - -function main({ encoding, n }) { - bench.start(); - for (var i = 0; i < n; ++i) { - const sd = new StringDecoder(encoding); - !!sd.encoding; - } - bench.end(n); -} diff --git a/deps/node/benchmark/string_decoder/string-decoder.js b/deps/node/benchmark/string_decoder/string-decoder.js deleted file mode 100644 index 0e34effb..00000000 --- a/deps/node/benchmark/string_decoder/string-decoder.js +++ /dev/null @@ -1,85 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const StringDecoder = require('string_decoder').StringDecoder; - -const bench = common.createBenchmark(main, { - encoding: ['ascii', 'utf8', 'base64-utf8', 'base64-ascii', 'utf16le'], - inLen: [32, 128, 1024, 4096], - chunkLen: [16, 64, 256, 1024], - n: [25e5] -}); - -const UTF8_ALPHA = 'Blåbærsyltetøy'; -const ASC_ALPHA = 'Blueberry jam'; -const UTF16_BUF = Buffer.from('Blåbærsyltetøy', 'utf16le'); - -function main({ encoding, inLen, chunkLen, n }) { - var alpha; - var buf; - const chunks = []; - var str = ''; - const isBase64 = (encoding === 'base64-ascii' || encoding === 'base64-utf8'); - var i; - - if (encoding === 'ascii' || encoding === 'base64-ascii') - alpha = ASC_ALPHA; - else if (encoding === 'utf8' || encoding === 'base64-utf8') - alpha = UTF8_ALPHA; - else if (encoding === 'utf16le') { - buf = UTF16_BUF; - str = Buffer.alloc(0); - } else - throw new Error('Bad encoding'); - - const sd = new StringDecoder(isBase64 ? 'base64' : encoding); - - for (i = 0; i < inLen; ++i) { - if (i > 0 && (i % chunkLen) === 0 && !isBase64) { - if (alpha) { - chunks.push(Buffer.from(str, encoding)); - str = ''; - } else { - chunks.push(str); - str = Buffer.alloc(0); - } - } - if (alpha) - str += alpha[i % alpha.length]; - else { - var start = i; - var end = i + 2; - if (i % 2 !== 0) { - ++start; - ++end; - } - str = Buffer.concat([ - str, - buf.slice(start % buf.length, end % buf.length), - ]); - } - } - - if (!alpha) { - if (str.length > 0) - chunks.push(str); - } else if (str.length > 0 && !isBase64) - chunks.push(Buffer.from(str, encoding)); - - if (isBase64) { - str = Buffer.from(str, 'utf8').toString('base64'); - while (str.length > 0) { - const len = Math.min(chunkLen, str.length); - chunks.push(Buffer.from(str.substring(0, len), 'utf8')); - str = str.substring(len); - } - } - - const nChunks = chunks.length; - - bench.start(); - for (i = 0; i < n; ++i) { - for (var j = 0; j < nChunks; ++j) - sd.write(chunks[j]); - } - bench.end(n); -} diff --git a/deps/node/benchmark/timers/immediate.js b/deps/node/benchmark/timers/immediate.js deleted file mode 100644 index ba50f961..00000000 --- a/deps/node/benchmark/timers/immediate.js +++ /dev/null @@ -1,114 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [5e6], - type: ['depth', 'depth1', 'breadth', 'breadth1', 'breadth4', 'clear'] -}); - -function main({ n, type }) { - switch (type) { - case 'depth': - depth(n); - break; - case 'depth1': - depth1(n); - break; - case 'breadth': - breadth(n); - break; - case 'breadth1': - breadth1(n); - break; - case 'breadth4': - breadth4(n); - break; - case 'clear': - clear(n); - break; - } -} - -// setImmediate tail recursion, 0 arguments -function depth(N) { - var n = 0; - bench.start(); - setImmediate(cb); - function cb() { - n++; - if (n === N) - bench.end(n); - else - setImmediate(cb); - } -} - -// setImmediate tail recursion, 1 argument -function depth1(N) { - var n = 0; - bench.start(); - setImmediate(cb, 1); - function cb(a1) { - n++; - if (n === N) - bench.end(N); - else - setImmediate(cb, 1); - } -} - -// Concurrent setImmediate, 0 arguments -function breadth(N) { - var n = 0; - bench.start(); - function cb() { - n++; - if (n === N) - bench.end(N); - } - for (var i = 0; i < N; i++) { - setImmediate(cb); - } -} - -// Concurrent setImmediate, 1 argument -function breadth1(N) { - var n = 0; - bench.start(); - function cb(a1) { - n++; - if (n === N) - bench.end(n); - } - for (var i = 0; i < N; i++) { - setImmediate(cb, 1); - } -} - -// Concurrent setImmediate, 4 arguments -function breadth4(N) { - N /= 2; - var n = 0; - bench.start(); - function cb(a1, a2, a3, a4) { - n++; - if (n === N) - bench.end(n); - } - for (var i = 0; i < N; i++) { - setImmediate(cb, 1, 2, 3, 4); - } -} - -function clear(N) { - N *= 4; - bench.start(); - function cb(a1) { - if (a1 === 2) - bench.end(N); - } - for (var i = 0; i < N; i++) { - clearImmediate(setImmediate(cb, 1)); - } - setImmediate(cb, 2); -} diff --git a/deps/node/benchmark/timers/set-immediate-breadth-args.js b/deps/node/benchmark/timers/set-immediate-breadth-args.js deleted file mode 100644 index 518ed90e..00000000 --- a/deps/node/benchmark/timers/set-immediate-breadth-args.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - - process.on('exit', () => { - bench.end(n); - }); - - function cb1(arg1) {} - function cb2(arg1, arg2) {} - function cb3(arg1, arg2, arg3) {} - - bench.start(); - for (let i = 0; i < n; i++) { - if (i % 3 === 0) - setImmediate(cb3, 512, true, null, 512, true, null); - else if (i % 2 === 0) - setImmediate(cb2, false, 5.1, 512); - else - setImmediate(cb1, 0); - } -} diff --git a/deps/node/benchmark/timers/set-immediate-breadth.js b/deps/node/benchmark/timers/set-immediate-breadth.js deleted file mode 100644 index 87bf9ee2..00000000 --- a/deps/node/benchmark/timers/set-immediate-breadth.js +++ /dev/null @@ -1,20 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [1e7] -}); - -function main({ n }) { - - process.on('exit', () => { - bench.end(n); - }); - - function cb() {} - - bench.start(); - for (let i = 0; i < n; i++) { - setImmediate(cb); - } -} diff --git a/deps/node/benchmark/timers/set-immediate-depth-args.js b/deps/node/benchmark/timers/set-immediate-depth-args.js deleted file mode 100644 index d8eb5c40..00000000 --- a/deps/node/benchmark/timers/set-immediate-depth-args.js +++ /dev/null @@ -1,46 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - n: [5e6] -}); - -function main({ n }) { - - process.on('exit', () => { - bench.end(n); - }); - - function cb3(n, arg2, arg3) { - if (--n) { - if (n % 3 === 0) - setImmediate(cb3, n, true, null, 5.1, null, true); - else if (n % 2 === 0) - setImmediate(cb2, n, 5.1, true); - else - setImmediate(cb1, n); - } - } - function cb2(n, arg2) { - if (--n) { - if (n % 3 === 0) - setImmediate(cb3, n, true, null, 5.1, null, true); - else if (n % 2 === 0) - setImmediate(cb2, n, 5.1, true); - else - setImmediate(cb1, n); - } - } - function cb1(n) { - if (--n) { - if (n % 3 === 0) - setImmediate(cb3, n, true, null, 5.1, null, true); - else if (n % 2 === 0) - setImmediate(cb2, n, 5.1, true); - else - setImmediate(cb1, n); - } - } - bench.start(); - setImmediate(cb1, n); -} diff --git a/deps/node/benchmark/timers/timers-breadth.js b/deps/node/benchmark/timers/timers-breadth.js deleted file mode 100644 index 8cd77f4f..00000000 --- a/deps/node/benchmark/timers/timers-breadth.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [5e6], -}); - -function main({ n }) { - var j = 0; - bench.start(); - function cb() { - j++; - if (j === n) - bench.end(n); - } - for (var i = 0; i < n; i++) { - setTimeout(cb, 1); - } -} diff --git a/deps/node/benchmark/timers/timers-cancel-pooled.js b/deps/node/benchmark/timers/timers-cancel-pooled.js deleted file mode 100644 index 6f16f3c9..00000000 --- a/deps/node/benchmark/timers/timers-cancel-pooled.js +++ /dev/null @@ -1,31 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [5e6], -}); - -function main({ n }) { - - var timer = setTimeout(() => {}, 1); - for (var i = 0; i < n; i++) { - setTimeout(cb, 1); - } - var next = timer._idlePrev; - clearTimeout(timer); - - bench.start(); - - for (var j = 0; j < n; j++) { - timer = next; - next = timer._idlePrev; - clearTimeout(timer); - } - - bench.end(n); -} - -function cb() { - assert.fail('Timer should not call callback'); -} diff --git a/deps/node/benchmark/timers/timers-cancel-unpooled.js b/deps/node/benchmark/timers/timers-cancel-unpooled.js deleted file mode 100644 index 1daf68bd..00000000 --- a/deps/node/benchmark/timers/timers-cancel-unpooled.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [1e6], - direction: ['start', 'end'] -}); - -function main({ n, direction }) { - - const timersList = []; - for (var i = 0; i < n; i++) { - timersList.push(setTimeout(cb, i + 1)); - } - - var j; - bench.start(); - if (direction === 'start') { - for (j = 0; j < n; j++) { - clearTimeout(timersList[j]); - } - } else { - for (j = n - 1; j >= 0; j--) { - clearTimeout(timersList[j]); - } - } - bench.end(n); -} - -function cb() { - assert.fail(`Timer ${this._idleTimeout} should not call callback`); -} diff --git a/deps/node/benchmark/timers/timers-depth.js b/deps/node/benchmark/timers/timers-depth.js deleted file mode 100644 index bfc6dd02..00000000 --- a/deps/node/benchmark/timers/timers-depth.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1e3], -}); - -function main({ n }) { - var i = 0; - bench.start(); - setTimeout(cb, 1); - function cb() { - i++; - if (i === n) - bench.end(n); - else - setTimeout(cb, 1); - } -} diff --git a/deps/node/benchmark/timers/timers-insert-pooled.js b/deps/node/benchmark/timers/timers-insert-pooled.js deleted file mode 100644 index a7441a9e..00000000 --- a/deps/node/benchmark/timers/timers-insert-pooled.js +++ /dev/null @@ -1,17 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [5e6], -}); - -function main({ n }) { - - bench.start(); - - for (var i = 0; i < n; i++) { - setTimeout(() => {}, 1); - } - - bench.end(n); -} diff --git a/deps/node/benchmark/timers/timers-insert-unpooled.js b/deps/node/benchmark/timers/timers-insert-unpooled.js deleted file mode 100644 index 232cc7c3..00000000 --- a/deps/node/benchmark/timers/timers-insert-unpooled.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - n: [1e6], - direction: ['start', 'end'] -}); - -function main({ direction, n }) { - const timersList = []; - - var i; - bench.start(); - if (direction === 'start') { - for (i = 1; i <= n; i++) { - timersList.push(setTimeout(cb, i)); - } - } else { - for (i = n; i > 0; i--) { - timersList.push(setTimeout(cb, i)); - } - } - bench.end(n); - - for (var j = 0; j < n; j++) { - clearTimeout(timersList[j]); - } -} - -function cb() { - assert.fail(`Timer ${this._idleTimeout} should not call callback`); -} diff --git a/deps/node/benchmark/timers/timers-timeout-nexttick.js b/deps/node/benchmark/timers/timers-timeout-nexttick.js deleted file mode 100644 index 781e505a..00000000 --- a/deps/node/benchmark/timers/timers-timeout-nexttick.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -// The following benchmark measures setting up n * 1e6 timeouts, -// as well as scheduling a next tick from each timeout. Those -// then get executed on the next uv tick. - -const bench = common.createBenchmark(main, { - n: [5e4, 5e6], -}); - -function main({ n }) { - let count = 0; - - // Function tracking on the hidden class in V8 can cause misleading - // results in this benchmark if only a single function is used — - // alternate between two functions for a fairer benchmark. - - function cb() { - process.nextTick(counter); - } - function cb2() { - process.nextTick(counter); - } - function counter() { - count++; - if (count === n) - bench.end(n); - } - - for (var i = 0; i < n; i++) { - setTimeout(i % 2 ? cb : cb2, 1); - } - - bench.start(); -} diff --git a/deps/node/benchmark/timers/timers-timeout-pooled.js b/deps/node/benchmark/timers/timers-timeout-pooled.js deleted file mode 100644 index d34080fa..00000000 --- a/deps/node/benchmark/timers/timers-timeout-pooled.js +++ /dev/null @@ -1,34 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -// The following benchmark measures setting up n * 1e6 timeouts, -// which then get executed on the next uv tick - -const bench = common.createBenchmark(main, { - n: [1e7], -}); - -function main({ n }) { - let count = 0; - - // Function tracking on the hidden class in V8 can cause misleading - // results in this benchmark if only a single function is used — - // alternate between two functions for a fairer benchmark - - function cb() { - count++; - if (count === n) - bench.end(n); - } - function cb2() { - count++; - if (count === n) - bench.end(n); - } - - for (var i = 0; i < n; i++) { - setTimeout(i % 2 ? cb : cb2, 1); - } - - bench.start(); -} diff --git a/deps/node/benchmark/timers/timers-timeout-unpooled.js b/deps/node/benchmark/timers/timers-timeout-unpooled.js deleted file mode 100644 index 19f0f6a4..00000000 --- a/deps/node/benchmark/timers/timers-timeout-unpooled.js +++ /dev/null @@ -1,36 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -// The following benchmark sets up n * 1e6 unpooled timeouts, -// then measures their execution on the next uv tick - -const bench = common.createBenchmark(main, { - n: [1e6], -}); - -function main({ n }) { - let count = 0; - - // Function tracking on the hidden class in V8 can cause misleading - // results in this benchmark if only a single function is used — - // alternate between two functions for a fairer benchmark - - function cb() { - count++; - if (count === n) - bench.end(n); - } - function cb2() { - count++; - if (count === n) - bench.end(n); - } - - for (var i = 0; i < n; i++) { - // unref().ref() will cause each of these timers to - // allocate their own handle - setTimeout(i % 2 ? cb : cb2, 1).unref().ref(); - } - - bench.start(); -} diff --git a/deps/node/benchmark/tls/convertprotocols.js b/deps/node/benchmark/tls/convertprotocols.js deleted file mode 100644 index 0ba6c6dd..00000000 --- a/deps/node/benchmark/tls/convertprotocols.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const tls = require('tls'); - -const bench = common.createBenchmark(main, { - n: [1, 50000] -}); - -function main({ n }) { - const input = ['ABC', 'XYZ123', 'FOO']; - var m = {}; - // First call dominates results - if (n > 1) { - tls.convertALPNProtocols(input, m); - m = {}; - } - bench.start(); - for (var i = 0; i < n; i++) - tls.convertALPNProtocols(input, m); - bench.end(n); -} diff --git a/deps/node/benchmark/tls/secure-pair.js b/deps/node/benchmark/tls/secure-pair.js deleted file mode 100644 index ed678b90..00000000 --- a/deps/node/benchmark/tls/secure-pair.js +++ /dev/null @@ -1,105 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - dur: [5], - securing: ['SecurePair', 'TLSSocket'], - size: [2, 1024, 1024 * 1024] -}); - -const fs = require('fs'); -const tls = require('tls'); -const net = require('net'); -const path = require('path'); - -const cert_dir = path.resolve(__dirname, '../../test/fixtures'); -const REDIRECT_PORT = 28347; - -function main({ dur, size, securing }) { - const chunk = Buffer.alloc(size, 'b'); - - const options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384', - isServer: true, - requestCert: true, - rejectUnauthorized: true, - }; - - const server = net.createServer(onRedirectConnection); - server.listen(REDIRECT_PORT, () => { - const proxy = net.createServer(onProxyConnection); - proxy.listen(common.PORT, () => { - const clientOptions = { - port: common.PORT, - ca: options.ca, - key: options.key, - cert: options.cert, - isServer: false, - rejectUnauthorized: false, - }; - const conn = tls.connect(clientOptions, () => { - setTimeout(() => { - const mbits = (received * 8) / (1024 * 1024); - bench.end(mbits); - if (conn) - conn.destroy(); - server.close(); - proxy.close(); - }, dur * 1000); - bench.start(); - conn.on('drain', write); - write(); - }); - conn.on('error', (e) => { - throw new Error(`Client error: ${e}`); - }); - - function write() { - while (false !== conn.write(chunk)); - } - }); - }); - - function onProxyConnection(conn) { - const client = net.connect(REDIRECT_PORT, () => { - switch (securing) { - case 'SecurePair': - securePair(conn, client); - break; - case 'TLSSocket': - secureTLSSocket(conn, client); - break; - default: - throw new Error('Invalid securing method'); - } - }); - } - - function securePair(conn, client) { - const serverCtx = tls.createSecureContext(options); - const serverPair = tls.createSecurePair(serverCtx, true, true, false); - conn.pipe(serverPair.encrypted); - serverPair.encrypted.pipe(conn); - serverPair.on('error', (error) => { - throw new Error(`Pair error: ${error}`); - }); - serverPair.cleartext.pipe(client); - } - - function secureTLSSocket(conn, client) { - const serverSocket = new tls.TLSSocket(conn, options); - serverSocket.on('error', (e) => { - throw new Error(`Socket error: ${e}`); - }); - serverSocket.pipe(client); - } - - let received = 0; - function onRedirectConnection(conn) { - conn.on('data', (chunk) => { - received += chunk.length; - }); - } -} diff --git a/deps/node/benchmark/tls/throughput.js b/deps/node/benchmark/tls/throughput.js deleted file mode 100644 index 3c0c2d4e..00000000 --- a/deps/node/benchmark/tls/throughput.js +++ /dev/null @@ -1,72 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - dur: [5], - type: ['buf', 'asc', 'utf'], - size: [2, 1024, 1024 * 1024] -}); - -const path = require('path'); -const fs = require('fs'); -const cert_dir = path.resolve(__dirname, '../../test/fixtures'); -var options; -const tls = require('tls'); - -function main({ dur, type, size }) { - var encoding; - var server; - var chunk; - switch (type) { - case 'buf': - chunk = Buffer.alloc(size, 'b'); - break; - case 'asc': - chunk = 'a'.repeat(size); - encoding = 'ascii'; - break; - case 'utf': - chunk = 'ü'.repeat(size / 2); - encoding = 'utf8'; - break; - default: - throw new Error('invalid type'); - } - - options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384' - }; - - server = tls.createServer(options, onConnection); - var conn; - server.listen(common.PORT, () => { - const opt = { port: common.PORT, rejectUnauthorized: false }; - conn = tls.connect(opt, () => { - setTimeout(done, dur * 1000); - bench.start(); - conn.on('drain', write); - write(); - }); - - function write() { - while (false !== conn.write(chunk, encoding)); - } - }); - - var received = 0; - function onConnection(conn) { - conn.on('data', (chunk) => { - received += chunk.length; - }); - } - - function done() { - const mbits = (received * 8) / (1024 * 1024); - bench.end(mbits); - if (conn) - conn.destroy(); - server.close(); - } -} diff --git a/deps/node/benchmark/tls/tls-connect.js b/deps/node/benchmark/tls/tls-connect.js deleted file mode 100644 index 470d536f..00000000 --- a/deps/node/benchmark/tls/tls-connect.js +++ /dev/null @@ -1,68 +0,0 @@ -'use strict'; -const fs = require('fs'); -const path = require('path'); -const tls = require('tls'); - -const common = require('../common.js'); -const bench = common.createBenchmark(main, { - concurrency: [1, 10], - dur: [5] -}); - -var clientConn = 0; -var serverConn = 0; -var dur; -var concurrency; -var running = true; - -function main(conf) { - dur = conf.dur; - concurrency = conf.concurrency; - const cert_dir = path.resolve(__dirname, '../../test/fixtures'); - const options = { - key: fs.readFileSync(`${cert_dir}/test_key.pem`), - cert: fs.readFileSync(`${cert_dir}/test_cert.pem`), - ca: [ fs.readFileSync(`${cert_dir}/test_ca.pem`) ], - ciphers: 'AES256-GCM-SHA384' - }; - - const server = tls.createServer(options, onConnection); - server.listen(common.PORT, onListening); -} - -function onListening() { - setTimeout(done, dur * 1000); - bench.start(); - for (var i = 0; i < concurrency; i++) - makeConnection(); -} - -function onConnection(conn) { - serverConn++; -} - -function makeConnection() { - const options = { - port: common.PORT, - rejectUnauthorized: false - }; - var conn = tls.connect(options, () => { - clientConn++; - conn.on('error', (er) => { - console.error('client error', er); - throw er; - }); - conn.end(); - if (running) makeConnection(); - }); -} - -function done() { - running = false; - // It's only an established connection if they both saw it. - // because we destroy the server somewhat abruptly, these - // don't always match. Generally, serverConn will be - // the smaller number, but take the min just to be sure. - bench.end(Math.min(serverConn, clientConn)); - process.exit(0); -} diff --git a/deps/node/benchmark/url/legacy-vs-whatwg-url-get-prop.js b/deps/node/benchmark/url/legacy-vs-whatwg-url-get-prop.js deleted file mode 100644 index 59bb4724..00000000 --- a/deps/node/benchmark/url/legacy-vs-whatwg-url-get-prop.js +++ /dev/null @@ -1,91 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); -const URL = url.URL; -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - type: common.urlDataTypes, - method: ['legacy', 'whatwg'], - e: [1] -}); - -function useLegacy(data) { - const obj = url.parse(data[0]); - const noDead = { - protocol: obj.protocol, - auth: obj.auth, - host: obj.host, - hostname: obj.hostname, - port: obj.port, - pathname: obj.pathname, - search: obj.search, - hash: obj.hash - }; - const len = data.length; - // It's necessary to assign the values to an object - // to avoid loop invariant code motion. - bench.start(); - for (var i = 0; i < len; i++) { - const obj = data[i]; - noDead.protocol = obj.protocol; - noDead.auth = obj.auth; - noDead.host = obj.host; - noDead.hostname = obj.hostname; - noDead.port = obj.port; - noDead.pathname = obj.pathname; - noDead.search = obj.search; - noDead.hash = obj.hash; - } - bench.end(len); - return noDead; -} - -function useWHATWG(data) { - const obj = new URL(data[0]); - const noDead = { - protocol: obj.protocol, - auth: `${obj.username}:${obj.password}`, - host: obj.host, - hostname: obj.hostname, - port: obj.port, - pathname: obj.pathname, - search: obj.search, - hash: obj.hash - }; - const len = data.length; - bench.start(); - for (var i = 0; i < len; i++) { - const obj = data[i]; - noDead.protocol = obj.protocol; - noDead.auth = `${obj.username}:${obj.password}`; - noDead.host = obj.host; - noDead.hostname = obj.hostname; - noDead.port = obj.port; - noDead.pathname = obj.pathname; - noDead.search = obj.search; - noDead.hash = obj.hash; - } - bench.end(len); - return noDead; -} - -function main({ type, method, e }) { - e = +e; - var data; - var noDead; // Avoid dead code elimination. - switch (method) { - case 'legacy': - data = common.bakeUrlData(type, e, false, false); - noDead = useLegacy(data.map((i) => url.parse(i))); - break; - case 'whatwg': - data = common.bakeUrlData(type, e, false, true); - noDead = useWHATWG(data); - break; - default: - throw new Error(`Unknown method "${method}"`); - } - - assert.ok(noDead); -} diff --git a/deps/node/benchmark/url/legacy-vs-whatwg-url-parse.js b/deps/node/benchmark/url/legacy-vs-whatwg-url-parse.js deleted file mode 100644 index e4af2e0b..00000000 --- a/deps/node/benchmark/url/legacy-vs-whatwg-url-parse.js +++ /dev/null @@ -1,67 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); -const URL = url.URL; -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - withBase: ['true', 'false'], - type: common.urlDataTypes, - e: [1], - method: ['legacy', 'whatwg'] -}); - -function useLegacy(data) { - const len = data.length; - var result = url.parse(data[0]); // avoid dead code elimination - bench.start(); - for (var i = 0; i < len; ++i) { - result = url.parse(data[i]); - } - bench.end(len); - return result; -} - -function useWHATWGWithBase(data) { - const len = data.length; - var result = new URL(data[0][0], data[0][1]); // avoid dead code elimination - bench.start(); - for (var i = 0; i < len; ++i) { - const item = data[i]; - result = new URL(item[0], item[1]); - } - bench.end(len); - return result; -} - -function useWHATWGWithoutBase(data) { - const len = data.length; - var result = new URL(data[0]); // avoid dead code elimination - bench.start(); - for (var i = 0; i < len; ++i) { - result = new URL(data[i]); - } - bench.end(len); - return result; -} - -function main({ e, method, type, withBase }) { - e = +e; - withBase = withBase === 'true'; - var noDead; // Avoid dead code elimination. - var data; - switch (method) { - case 'legacy': - data = common.bakeUrlData(type, e, false, false); - noDead = useLegacy(data); - break; - case 'whatwg': - data = common.bakeUrlData(type, e, withBase, false); - noDead = withBase ? useWHATWGWithBase(data) : useWHATWGWithoutBase(data); - break; - default: - throw new Error(`Unknown method ${method}`); - } - - assert.ok(noDead); -} diff --git a/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js b/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js deleted file mode 100644 index 81b5b6dc..00000000 --- a/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-parse.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { URLSearchParams } = require('url'); -const querystring = require('querystring'); -const searchParams = common.searchParams; - -const bench = common.createBenchmark(main, { - searchParam: Object.keys(searchParams), - method: ['legacy', 'whatwg'], - n: [1e6] -}); - -function useLegacy(n, input) { - querystring.parse(input); - bench.start(); - for (var i = 0; i < n; i += 1) { - querystring.parse(input); - } - bench.end(n); -} - -function useWHATWG(n, param) { - new URLSearchParams(param); - bench.start(); - for (var i = 0; i < n; i += 1) { - new URLSearchParams(param); - } - bench.end(n); -} - -function main({ searchParam, n, method }) { - const param = searchParams[searchParam]; - if (!param) { - throw new Error(`Unknown search parameter type "${searchParam}"`); - } - - switch (method) { - case 'legacy': - useLegacy(n, param); - break; - case 'whatwg': - useWHATWG(n, param); - break; - default: - throw new Error(`Unknown method ${method}`); - } -} diff --git a/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js b/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js deleted file mode 100644 index f97961de..00000000 --- a/deps/node/benchmark/url/legacy-vs-whatwg-url-searchparams-serialize.js +++ /dev/null @@ -1,49 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { URLSearchParams } = require('url'); -const querystring = require('querystring'); -const searchParams = common.searchParams; - -const bench = common.createBenchmark(main, { - searchParam: Object.keys(searchParams), - method: ['legacy', 'whatwg'], - n: [1e6] -}); - -function useLegacy(n, input, prop) { - const obj = querystring.parse(input); - querystring.stringify(obj); - bench.start(); - for (var i = 0; i < n; i += 1) { - querystring.stringify(obj); - } - bench.end(n); -} - -function useWHATWG(n, param, prop) { - const obj = new URLSearchParams(param); - obj.toString(); - bench.start(); - for (var i = 0; i < n; i += 1) { - obj.toString(); - } - bench.end(n); -} - -function main({ searchParam, n, method }) { - const param = searchParams[searchParam]; - if (!param) { - throw new Error(`Unknown search parameter type "${searchParam}"`); - } - - switch (method) { - case 'legacy': - useLegacy(n, param); - break; - case 'whatwg': - useWHATWG(n, param); - break; - default: - throw new Error(`Unknown method ${method}`); - } -} diff --git a/deps/node/benchmark/url/legacy-vs-whatwg-url-serialize.js b/deps/node/benchmark/url/legacy-vs-whatwg-url-serialize.js deleted file mode 100644 index e4c821cb..00000000 --- a/deps/node/benchmark/url/legacy-vs-whatwg-url-serialize.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); -const URL = url.URL; -const assert = require('assert'); - -const bench = common.createBenchmark(main, { - type: common.urlDataTypes, - method: ['legacy', 'whatwg'], - e: [1] -}); - -function useLegacy(data) { - const obj = url.parse(data[0]); - const len = data.length; - var noDead = url.format(obj); - bench.start(); - for (var i = 0; i < len; i++) { - noDead = data[i].toString(); - } - bench.end(len); - return noDead; -} - -function useWHATWG(data) { - const obj = new URL(data[0]); - const len = data.length; - var noDead = obj.toString(); - bench.start(); - for (var i = 0; i < len; i++) { - noDead = data[i].toString(); - } - bench.end(len); - return noDead; -} - -function main({ type, e, method }) { - e = +e; - const data = common.bakeUrlData(type, e, false, false); - - var noDead; // Avoid dead code elimination. - switch (method) { - case 'legacy': - noDead = useLegacy(data); - break; - case 'whatwg': - noDead = useWHATWG(data); - break; - default: - throw new Error(`Unknown method ${method}`); - } - - assert.ok(noDead); -} diff --git a/deps/node/benchmark/url/url-format.js b/deps/node/benchmark/url/url-format.js deleted file mode 100644 index 14696af8..00000000 --- a/deps/node/benchmark/url/url-format.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); - -const inputs = { - slashes: { slashes: true, host: 'localhost' }, - file: { protocol: 'file:', pathname: '/foo' }, -}; - -const bench = common.createBenchmark(main, { - type: Object.keys(inputs), - n: [25e6] -}); - -function main({ type, n }) { - const input = inputs[type] || ''; - - // Force-optimize url.format() so that the benchmark doesn't get - // disrupted by the optimizer kicking in halfway through. - for (const name in inputs) - url.format(inputs[name]); - - bench.start(); - for (var i = 0; i < n; i += 1) - url.format(input); - bench.end(n); -} diff --git a/deps/node/benchmark/url/url-parse.js b/deps/node/benchmark/url/url-parse.js deleted file mode 100644 index 83f626cc..00000000 --- a/deps/node/benchmark/url/url-parse.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); - -const inputs = { - normal: 'http://foo.com/bar', - escaped: 'https://foo.bar/{}^`/abcd' -}; - -const bench = common.createBenchmark(main, { - type: Object.keys(inputs), - n: [1e7] -}); - -function main({ type, n }) { - const input = inputs[type] || ''; - - bench.start(); - for (var i = 0; i < n; i += 1) - url.parse(input); - bench.end(n); -} diff --git a/deps/node/benchmark/url/url-resolve.js b/deps/node/benchmark/url/url-resolve.js deleted file mode 100644 index bd584c6f..00000000 --- a/deps/node/benchmark/url/url-resolve.js +++ /dev/null @@ -1,29 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const url = require('url'); -const hrefs = common.urls; -hrefs.noscheme = 'some.ran/dom/url.thing?oh=yes#whoo'; - -const paths = { - 'up': '../../../../../etc/passwd', - 'sibling': '../foo/bar?baz=boom', - 'foo/bar': 'foo/bar', - 'withscheme': 'http://nodejs.org', - 'down': './foo/bar?baz' -}; - -const bench = common.createBenchmark(main, { - href: Object.keys(hrefs), - path: Object.keys(paths), - n: [1e5] -}); - -function main({ n, href, path }) { - const h = hrefs[href]; - const p = paths[path]; - - bench.start(); - for (var i = 0; i < n; i += 1) - url.resolve(h, p); - bench.end(n); -} diff --git a/deps/node/benchmark/url/url-searchparams-iteration.js b/deps/node/benchmark/url/url-searchparams-iteration.js deleted file mode 100644 index 244c9550..00000000 --- a/deps/node/benchmark/url/url-searchparams-iteration.js +++ /dev/null @@ -1,58 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const assert = require('assert'); -const { URLSearchParams } = require('url'); - -const bench = common.createBenchmark(main, { - loopMethod: ['forEach', 'iterator'], - n: [1e6] -}); - -const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; - -function forEach(n) { - const params = new URLSearchParams(str); - const noDead = []; - const cb = (val, key) => { - noDead[0] = key; - noDead[1] = val; - }; - - bench.start(); - for (var i = 0; i < n; i += 1) - params.forEach(cb); - bench.end(n); - - assert.strictEqual(noDead[0], 'three'); - assert.strictEqual(noDead[1], '3rd'); -} - -function iterator(n) { - const params = new URLSearchParams(str); - const noDead = []; - - bench.start(); - for (var i = 0; i < n; i += 1) { - for (const pair of params) { - noDead[0] = pair[0]; - noDead[1] = pair[1]; - } - } - bench.end(n); - - assert.strictEqual(noDead[0], 'three'); - assert.strictEqual(noDead[1], '3rd'); -} - -function main({ loopMethod, n }) { - switch (loopMethod) { - case 'forEach': - forEach(n); - break; - case 'iterator': - iterator(n); - break; - default: - throw new Error(`Unknown method ${loopMethod}`); - } -} diff --git a/deps/node/benchmark/url/url-searchparams-read.js b/deps/node/benchmark/url/url-searchparams-read.js deleted file mode 100644 index 2eb0a4f2..00000000 --- a/deps/node/benchmark/url/url-searchparams-read.js +++ /dev/null @@ -1,22 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { URLSearchParams } = require('url'); - -const bench = common.createBenchmark(main, { - accessMethod: ['get', 'getAll', 'has'], - param: ['one', 'two', 'three', 'nonexistent'], - n: [2e7] -}); - -const str = 'one=single&two=first&three=first&two=2nd&three=2nd&three=3rd'; - -function main({ accessMethod, param, n }) { - const params = new URLSearchParams(str); - if (!params[accessMethod]) - throw new Error(`Unknown method ${accessMethod}`); - - bench.start(); - for (var i = 0; i < n; i += 1) - params[accessMethod](param); - bench.end(n); -} diff --git a/deps/node/benchmark/url/url-searchparams-sort.js b/deps/node/benchmark/url/url-searchparams-sort.js deleted file mode 100644 index 6720b66d..00000000 --- a/deps/node/benchmark/url/url-searchparams-sort.js +++ /dev/null @@ -1,47 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const URLSearchParams = require('url').URLSearchParams; - -const inputs = { - wpt: 'wpt', // to work around tests - empty: '', - sorted: 'a&b&c&d&e&f&g&h&i&j&k&l&m&n&o&p&q&r&s&t&u&v&w&x&y&z', - almostsorted: 'a&b&c&d&e&f&g&i&h&j&k&l&m&n&o&p&q&r&s&t&u&w&v&x&y&z', - reversed: 'z&y&x&w&v&u&t&s&r&q&p&o&n&m&l&k&j&i&h&g&f&e&d&c&b&a', - random: 'm&t&d&c&z&v&a&n&p&y&u&o&h&l&f&j&e&q&b&i&s&x&k&w&r&g', - // 8 parameters - short: 'm&t&d&c&z&v&a&n', - // 88 parameters - long: 'g&r&t&h&s&r&d&w&b&n&h&k&x&m&k&h&o&e&x&c&c&g&e&b&p&p&s&n&j&b&y&z&' + - 'u&l&o&r&w&a&u&l&m&f&j&q&p&f&e&y&e&n&e&l&m&w&u&w&t&n&t&q&v&y&c&o&' + - 'k&f&j&i&l&m&g&j&d&i&z&q&p&x&q&q&d&n&y&w&g&i&v&r' -}; - -function getParams(str) { - const out = []; - for (const key of str.split('&')) { - out.push(key, ''); - } - return out; -} - -const bench = common.createBenchmark(main, { - type: Object.keys(inputs), - n: [1e6] -}, { - flags: ['--expose-internals'] -}); - -function main({ type, n }) { - const searchParams = require('internal/url').searchParamsSymbol; - const input = inputs[type]; - const params = new URLSearchParams(); - const array = getParams(input); - - bench.start(); - for (var i = 0; i < n; i++) { - params[searchParams] = array.slice(); - params.sort(); - } - bench.end(n); -} diff --git a/deps/node/benchmark/url/usvstring.js b/deps/node/benchmark/url/usvstring.js deleted file mode 100644 index 91abe8d6..00000000 --- a/deps/node/benchmark/url/usvstring.js +++ /dev/null @@ -1,27 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const inputs = { - valid: 'adsfadsfadsf', - validsurr: '\uda23\ude23\uda1f\udfaa\ud800\udfff\uda23\ude23\uda1f\udfaa' + - '\ud800\udfff', - someinvalid: 'asasfdfasd\uda23', - allinvalid: '\udc45\uda23 \udf00\udc00 \udfaa\uda12 \udc00\udfaa', - nonstring: { toString() { return 'asdf'; } } -}; -const bench = common.createBenchmark(main, { - input: Object.keys(inputs), - n: [5e7] -}, { - flags: ['--expose-internals'] -}); - -function main({ input, n }) { - const { toUSVString } = require('internal/url'); - const str = inputs[input]; - - bench.start(); - for (var i = 0; i < n; i++) - toUSVString(str); - bench.end(n); -} diff --git a/deps/node/benchmark/url/whatwg-url-idna.js b/deps/node/benchmark/url/whatwg-url-idna.js deleted file mode 100644 index b67a08da..00000000 --- a/deps/node/benchmark/url/whatwg-url-idna.js +++ /dev/null @@ -1,43 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const { domainToASCII, domainToUnicode } = require('url'); - -const domains = { - empty: { - ascii: '', - unicode: '' - }, - none: { - ascii: 'passports', - unicode: 'passports' - }, - some: { - ascii: 'Paßstraße', - unicode: 'xn--Pastrae-1vae' - }, - all: { - ascii: '他们不说中文', - unicode: 'xn--ihqwczyycu19kkg2c' - }, - nonstring: { - ascii: { toString() { return ''; } }, - unicode: { toString() { return ''; } } - } -}; - -const bench = common.createBenchmark(main, { - domain: Object.keys(domains), - to: ['ascii', 'unicode'], - n: [5e6] -}); - -function main({ n, to, domain }) { - const value = domains[domain][to]; - const method = to === 'ascii' ? domainToASCII : domainToUnicode; - - bench.start(); - for (var i = 0; i < n; i++) { - method(value); - } - bench.end(n); -} diff --git a/deps/node/benchmark/url/whatwg-url-properties.js b/deps/node/benchmark/url/whatwg-url-properties.js deleted file mode 100644 index 6961fec4..00000000 --- a/deps/node/benchmark/url/whatwg-url-properties.js +++ /dev/null @@ -1,60 +0,0 @@ -'use strict'; -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - withBase: ['true', 'false'], - type: ['wpt'], // Too many combinations - just use WPT by default - e: [1], - prop: ['href', 'origin', 'protocol', - 'username', 'password', 'host', 'hostname', 'port', - 'pathname', 'search', 'searchParams', 'hash'] -}); - -function setAndGet(data, prop) { - const len = data.length; - var result = data[0][prop]; - bench.start(); - for (var i = 0; i < len; ++i) { - result = data[i][prop]; - data[i][prop] = result; - } - bench.end(len); - return result; -} - -function get(data, prop) { - const len = data.length; - var result = data[0][prop]; - bench.start(); - for (var i = 0; i < len; ++i) { - result = data[i][prop]; // get - } - bench.end(len); - return result; -} - -function main({ e, type, prop, withBase }) { - e = +e; - withBase = withBase === 'true'; - const data = common.bakeUrlData(type, e, withBase, true); - switch (prop) { - case 'protocol': - case 'username': - case 'password': - case 'host': - case 'hostname': - case 'port': - case 'pathname': - case 'search': - case 'hash': - case 'href': - setAndGet(data, prop); - break; - case 'origin': - case 'searchParams': - get(data, prop); - break; - default: - throw new Error('Unknown prop'); - } -} diff --git a/deps/node/benchmark/util/format.js b/deps/node/benchmark/util/format.js deleted file mode 100644 index 2a4a2009..00000000 --- a/deps/node/benchmark/util/format.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; - -const util = require('util'); -const common = require('../common'); - -const inputs = { - 'string': ['Hello, my name is %s', 'Fred'], - 'string-2': ['Hello, %s is my name', 'Fred'], - 'number': ['Hi, I was born in %d', 1989], - 'replace-object': ['An error occurred %j', { msg: 'This is an error' }], - 'unknown': ['hello %a', 'test'], - 'no-replace': [1, 2], - 'no-replace-2': ['foobar', 'yeah', 'mensch', 5], - 'only-objects': [{ msg: 'This is an error' }, { msg: 'This is an error' }], - 'many-%': ['replace%%%%s%%%%many%s%s%s', 'percent'], -}; - -const bench = common.createBenchmark(main, { - n: [1e5], - type: Object.keys(inputs) -}); - -function main({ n, type }) { - // For testing, if supplied with an empty type, default to string. - const [first, second] = inputs[type || 'string']; - - bench.start(); - for (var i = 0; i < n; i++) { - util.format(first, second); - } - bench.end(n); -} diff --git a/deps/node/benchmark/util/inspect-array.js b/deps/node/benchmark/util/inspect-array.js deleted file mode 100644 index 4fd73785..00000000 --- a/deps/node/benchmark/util/inspect-array.js +++ /dev/null @@ -1,45 +0,0 @@ -'use strict'; - -const common = require('../common'); -const util = require('util'); - -const bench = common.createBenchmark(main, { - n: [5e2], - len: [1e2, 1e5], - type: [ - 'denseArray', - 'sparseArray', - 'mixedArray', - 'denseArray_showHidden', - ] -}); - -function main({ n, len, type }) { - var arr = Array(len); - var i, opts; - - switch (type) { - case 'denseArray_showHidden': - opts = { showHidden: true }; - arr = arr.fill('denseArray'); - break; - // For testing, if supplied with an empty type, default to denseArray. - case '': - case 'denseArray': - arr = arr.fill('denseArray'); - break; - case 'sparseArray': - break; - case 'mixedArray': - for (i = 0; i < n; i += 2) - arr[i] = i; - break; - default: - throw new Error(`Unsupported type ${type}`); - } - bench.start(); - for (i = 0; i < n; i++) { - util.inspect(arr, opts); - } - bench.end(n); -} diff --git a/deps/node/benchmark/util/inspect-proxy.js b/deps/node/benchmark/util/inspect-proxy.js deleted file mode 100644 index 3c82d50a..00000000 --- a/deps/node/benchmark/util/inspect-proxy.js +++ /dev/null @@ -1,15 +0,0 @@ -'use strict'; - -const util = require('util'); -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { n: [2e4] }); - -function main({ n }) { - const proxyA = new Proxy({}, { get: () => {} }); - const proxyB = new Proxy(() => {}, {}); - bench.start(); - for (var i = 0; i < n; i += 1) - util.inspect({ a: proxyA, b: proxyB }, { showProxy: true }); - bench.end(n); -} diff --git a/deps/node/benchmark/util/inspect.js b/deps/node/benchmark/util/inspect.js deleted file mode 100644 index fd6f6158..00000000 --- a/deps/node/benchmark/util/inspect.js +++ /dev/null @@ -1,102 +0,0 @@ -'use strict'; -const util = require('util'); - -const common = require('../common.js'); - -const opts = { - showHidden: { showHidden: true }, - colors: { colors: true }, - none: undefined -}; -const bench = common.createBenchmark(main, { - n: [2e4], - method: [ - 'Object', - 'Object_empty', - 'Object_deep_ln', - 'String', - 'String_complex', - 'String_boxed', - 'Date', - 'Set', - 'Error', - 'Array', - 'TypedArray', - 'TypedArray_extra', - 'Number', - ], - option: Object.keys(opts) -}); - -function benchmark(n, obj, options) { - bench.start(); - for (var i = 0; i < n; i += 1) { - util.inspect(obj, options); - } - bench.end(n); -} - -function main({ method, n, option }) { - var obj; - const options = opts[option]; - switch (method) { - case 'Object': - benchmark(n, { a: 'a', b: 'b', c: 'c', d: 'd' }, options); - break; - case 'Object_empty': - benchmark(n, {}, options); - break; - case 'Object_deep_ln': - if (options) - options.depth = Infinity; - obj = { first: - { second: - { third: - { a: 'first', - b: 'second', - c: 'third', - d: 'fourth', - e: 'fifth', - f: 'sixth', - g: 'seventh' } } } }; - benchmark(n, obj, options || { depth: Infinity }); - break; - case 'String': - benchmark(n, 'Simple string', options); - break; - case 'String_complex': - benchmark(n, 'This string\nhas to be\tescaped!', options); - break; - case 'String_boxed': - benchmark(n, new String('string'), options); - break; - case 'Date': - benchmark(n, new Date(), options); - break; - case 'Set': - obj = new Set([5, 3]); - benchmark(n, obj, options); - break; - case 'Error': - benchmark(n, new Error('error'), options); - break; - case 'Array': - benchmark(n, Array(50).fill().map((_, i) => i), options); - break; - case 'TypedArray': - obj = new Uint8Array(Array(50).fill().map((_, i) => i)); - benchmark(n, obj, options); - break; - case 'TypedArray_extra': - obj = new Uint8Array(Array(50).fill().map((_, i) => i)); - obj.foo = 'bar'; - obj[Symbol('baz')] = 5; - benchmark(n, obj, options); - break; - case 'Number': - benchmark(n, 0, options); - break; - default: - throw new Error(`Unsupported method "${method}"`); - } -} diff --git a/deps/node/benchmark/util/normalize-encoding.js b/deps/node/benchmark/util/normalize-encoding.js deleted file mode 100644 index 464bda52..00000000 --- a/deps/node/benchmark/util/normalize-encoding.js +++ /dev/null @@ -1,59 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const assert = require('assert'); - -const groupedInputs = { - group_common: ['undefined', 'utf8', 'utf-8', 'base64', - 'binary', 'latin1', 'ucs2'], - group_upper: ['UTF-8', 'UTF8', 'UCS2', - 'UTF16LE', 'BASE64', 'UCS2'], - group_uncommon: ['foo'], - group_misc: ['', 'utf16le', 'hex', 'HEX', 'BINARY'] -}; - -const inputs = [ - '', 'utf8', 'utf-8', 'UTF-8', 'UTF8', 'Utf8', - 'ucs2', 'UCS2', 'utf16le', 'UTF16LE', - 'binary', 'BINARY', 'latin1', 'base64', 'BASE64', - 'hex', 'HEX', 'foo', 'undefined', -]; - -const bench = common.createBenchmark(main, { - input: inputs.concat(Object.keys(groupedInputs)), - n: [1e5] -}, { - flags: '--expose-internals' -}); - -function getInput(input) { - switch (input) { - case 'group_common': - return groupedInputs.group_common; - case 'group_upper': - return groupedInputs.group_upper; - case 'group_uncommon': - return groupedInputs.group_uncommon; - case 'group_misc': - return groupedInputs.group_misc; - case 'undefined': - return [undefined]; - default: - return [input]; - } -} - -function main({ input, n }) { - const { normalizeEncoding } = require('internal/util'); - const inputs = getInput(input); - var noDead = ''; - - bench.start(); - for (var i = 0; i < n; ++i) { - for (var j = 0; j < inputs.length; ++j) { - noDead = normalizeEncoding(inputs[j]); - } - } - bench.end(n); - assert.ok(noDead === undefined || noDead.length > 0); -} diff --git a/deps/node/benchmark/util/priority-queue.js b/deps/node/benchmark/util/priority-queue.js deleted file mode 100644 index 9cff7cbb..00000000 --- a/deps/node/benchmark/util/priority-queue.js +++ /dev/null @@ -1,18 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const bench = common.createBenchmark(main, { - n: [1e5] -}, { flags: ['--expose-internals'] }); - -function main({ n, type }) { - const PriorityQueue = require('internal/priority_queue'); - const queue = new PriorityQueue(); - bench.start(); - for (var i = 0; i < n; i++) - queue.insert(Math.random() * 1e7 | 0); - for (i = 0; i < n; i++) - queue.shift(); - bench.end(n); -} diff --git a/deps/node/benchmark/util/splice-one.js b/deps/node/benchmark/util/splice-one.js deleted file mode 100644 index 4ca7c856..00000000 --- a/deps/node/benchmark/util/splice-one.js +++ /dev/null @@ -1,33 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const bench = common.createBenchmark(main, { - n: [1e5], - pos: ['start', 'middle', 'end'], - size: [10, 100, 500], -}, { flags: ['--expose-internals'] }); - -function main({ n, pos, size }) { - const { spliceOne } = require('internal/util'); - const arr = new Array(size); - arr.fill(''); - let index; - switch (pos) { - case 'end': - index = size - 1; - break; - case 'middle': - index = Math.floor(size / 2); - break; - default: // start - index = 0; - } - - bench.start(); - for (var i = 0; i < n; i++) { - spliceOne(arr, index); - arr.push(''); - } - bench.end(n); -} diff --git a/deps/node/benchmark/util/type-check.js b/deps/node/benchmark/util/type-check.js deleted file mode 100644 index f1147198..00000000 --- a/deps/node/benchmark/util/type-check.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; - -const common = require('../common'); - -const arrayBuffer = new ArrayBuffer(); -const dataView = new DataView(arrayBuffer); -const uint8Array = new Uint8Array(arrayBuffer); -const int32Array = new Int32Array(arrayBuffer); - -const args = { - ArrayBufferView: { - 'true': dataView, - 'false-primitive': true, - 'false-object': arrayBuffer - }, - TypedArray: { - 'true': int32Array, - 'false-primitive': true, - 'false-object': arrayBuffer - }, - Uint8Array: { - 'true': uint8Array, - 'false-primitive': true, - 'false-object': int32Array - } -}; - -const bench = common.createBenchmark(main, { - type: Object.keys(args), - version: ['native', 'js'], - argument: ['true', 'false-primitive', 'false-object'], - n: [1e5] -}, { - flags: ['--expose-internals'] -}); - -function main({ type, argument, version, n }) { - // For testing, if supplied with an empty type, default to ArrayBufferView. - type = type || 'ArrayBufferView'; - - const util = common.binding('util'); - const types = require('internal/util/types'); - - const func = { native: util, js: types }[version][`is${type}`]; - const arg = args[type][argument]; - - bench.start(); - for (var i = 0; i < n; i++) { - func(arg); - } - bench.end(n); -} diff --git a/deps/node/benchmark/v8/get-stats.js b/deps/node/benchmark/v8/get-stats.js deleted file mode 100644 index aa1f0516..00000000 --- a/deps/node/benchmark/v8/get-stats.js +++ /dev/null @@ -1,19 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const v8 = require('v8'); - -const bench = common.createBenchmark(main, { - method: [ - 'getHeapStatistics', - 'getHeapSpaceStatistics', - ], - n: [1e6] -}); - -function main({ method, n }) { - bench.start(); - for (var i = 0; i < n; i++) - v8[method](); - bench.end(n); -} diff --git a/deps/node/benchmark/vm/run-in-context.js b/deps/node/benchmark/vm/run-in-context.js deleted file mode 100644 index 9b57067a..00000000 --- a/deps/node/benchmark/vm/run-in-context.js +++ /dev/null @@ -1,26 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1], - breakOnSigint: [0, 1], - withSigintListener: [0, 1] -}); - -const vm = require('vm'); - -function main({ n, breakOnSigint, withSigintListener }) { - const options = breakOnSigint ? { breakOnSigint: true } : {}; - - process.removeAllListeners('SIGINT'); - if (withSigintListener) - process.on('SIGINT', () => {}); - - const contextifiedSandbox = vm.createContext(); - - bench.start(); - for (var i = 0; i < n; i++) - vm.runInContext('0', contextifiedSandbox, options); - bench.end(n); -} diff --git a/deps/node/benchmark/vm/run-in-this-context.js b/deps/node/benchmark/vm/run-in-this-context.js deleted file mode 100644 index 07542873..00000000 --- a/deps/node/benchmark/vm/run-in-this-context.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -const common = require('../common.js'); - -const bench = common.createBenchmark(main, { - n: [1], - breakOnSigint: [0, 1], - withSigintListener: [0, 1] -}); - -const vm = require('vm'); - -function main({ n, breakOnSigint, withSigintListener }) { - const options = breakOnSigint ? { breakOnSigint: true } : {}; - - process.removeAllListeners('SIGINT'); - if (withSigintListener) - process.on('SIGINT', () => {}); - - bench.start(); - for (var i = 0; i < n; i++) - vm.runInThisContext('0', options); - bench.end(n); -} diff --git a/deps/node/benchmark/worker/echo.js b/deps/node/benchmark/worker/echo.js deleted file mode 100644 index 3e729d0e..00000000 --- a/deps/node/benchmark/worker/echo.js +++ /dev/null @@ -1,73 +0,0 @@ -'use strict'; - -const common = require('../common.js'); -const path = require('path'); -const bench = common.createBenchmark(main, { - workers: [1], - payload: ['string', 'object'], - sendsPerBroadcast: [1, 10], - n: [1e5] -}); - -const workerPath = path.resolve(__dirname, '..', 'fixtures', 'echo.worker.js'); - -function main(conf) { - const { Worker } = require('worker_threads'); - - const n = +conf.n; - const workers = +conf.workers; - const sends = +conf.sendsPerBroadcast; - const expectedPerBroadcast = sends * workers; - var payload; - var readies = 0; - var broadcasts = 0; - var msgCount = 0; - - switch (conf.payload) { - case 'string': - payload = 'hello world!'; - break; - case 'object': - payload = { action: 'pewpewpew', powerLevel: 9001 }; - break; - default: - throw new Error('Unsupported payload type'); - } - - const workerObjs = []; - - for (var i = 0; i < workers; ++i) { - const worker = new Worker(workerPath); - workerObjs.push(worker); - worker.on('online', onOnline); - worker.on('message', onMessage); - } - - function onOnline() { - if (++readies === workers) { - bench.start(); - broadcast(); - } - } - - function broadcast() { - if (broadcasts++ === n) { - bench.end(n); - for (const worker of workerObjs) { - worker.unref(); - } - return; - } - for (const worker of workerObjs) { - for (var i = 0; i < sends; ++i) - worker.postMessage(payload); - } - } - - function onMessage() { - if (++msgCount === expectedPerBroadcast) { - msgCount = 0; - broadcast(); - } - } -} diff --git a/deps/node/benchmark/zlib/creation.js b/deps/node/benchmark/zlib/creation.js deleted file mode 100644 index 30e6afe6..00000000 --- a/deps/node/benchmark/zlib/creation.js +++ /dev/null @@ -1,32 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const zlib = require('zlib'); - -const bench = common.createBenchmark(main, { - type: [ - 'Deflate', 'DeflateRaw', 'Inflate', 'InflateRaw', 'Gzip', 'Gunzip', 'Unzip', - 'BrotliCompress', 'BrotliDecompress', - ], - options: ['true', 'false'], - n: [5e5] -}); - -function main({ n, type, options }) { - const fn = zlib[`create${type}`]; - if (typeof fn !== 'function') - throw new Error('Invalid zlib type'); - var i = 0; - - if (options === 'true') { - const opts = {}; - bench.start(); - for (; i < n; ++i) - fn(opts); - bench.end(n); - } else { - bench.start(); - for (; i < n; ++i) - fn(); - bench.end(n); - } -} diff --git a/deps/node/benchmark/zlib/deflate.js b/deps/node/benchmark/zlib/deflate.js deleted file mode 100644 index 5e86d659..00000000 --- a/deps/node/benchmark/zlib/deflate.js +++ /dev/null @@ -1,52 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const zlib = require('zlib'); - -const bench = common.createBenchmark(main, { - method: ['createDeflate', 'deflate', 'deflateSync'], - inputLen: [1024], - n: [4e5] -}); - -function main({ n, method, inputLen }) { - const chunk = Buffer.alloc(inputLen, 'a'); - - var i = 0; - switch (method) { - // Performs `n` writes for a single deflate stream - case 'createDeflate': - var deflater = zlib.createDeflate(); - deflater.resume(); - deflater.on('finish', () => { - bench.end(n); - }); - - bench.start(); - (function next() { - if (i++ === n) - return deflater.end(); - deflater.write(chunk, next); - })(); - break; - // Performs `n` single deflate operations - case 'deflate': - var deflate = zlib.deflate; - bench.start(); - (function next(err, result) { - if (i++ === n) - return bench.end(n); - deflate(chunk, next); - })(); - break; - // Performs `n` single deflateSync operations - case 'deflateSync': - var deflateSync = zlib.deflateSync; - bench.start(); - for (; i < n; ++i) - deflateSync(chunk); - bench.end(n); - break; - default: - throw new Error('Unsupported deflate method'); - } -} diff --git a/deps/node/benchmark/zlib/pipe.js b/deps/node/benchmark/zlib/pipe.js deleted file mode 100644 index 6a1c427b..00000000 --- a/deps/node/benchmark/zlib/pipe.js +++ /dev/null @@ -1,42 +0,0 @@ -'use strict'; -const common = require('../common.js'); -const fs = require('fs'); -const zlib = require('zlib'); - -const bench = common.createBenchmark(main, { - inputLen: [1024], - duration: [5], - type: ['string', 'buffer'], - algorithm: ['gzip', 'brotli'] -}); - -function main({ inputLen, duration, type, algorithm }) { - const buffer = Buffer.alloc(inputLen, fs.readFileSync(__filename)); - const chunk = type === 'buffer' ? buffer : buffer.toString('utf8'); - - const input = algorithm === 'gzip' ? - zlib.createGzip() : zlib.createBrotliCompress(); - const output = algorithm === 'gzip' ? - zlib.createGunzip() : zlib.createBrotliDecompress(); - - let readFromOutput = 0; - input.pipe(output); - if (type === 'string') - output.setEncoding('utf8'); - output.on('data', (chunk) => readFromOutput += chunk.length); - - function write() { - input.write(chunk, write); - } - - bench.start(); - write(); - - setTimeout(() => { - // Give result in GBit/s, like the net benchmarks do - bench.end(readFromOutput * 8 / (1024 ** 3)); - - // Cut off writing the easy way. - input.write = () => {}; - }, duration * 1000); -} |