| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,8 @@ | |||
| 1 | + const { PassThrough } = require('node:stream'); | ||
| 2 | + | ||
| 3 | + module.exports = new PassThrough({ | ||
| 4 | + objectMode: true, | ||
| 5 | + transform(chunk, encoding, callback) { | ||
| 6 | + callback(null) | ||
| 7 | + }, | ||
| 8 | + }); | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const { it } = require('node:test'); | ||
| 4 | + | ||
| 5 | + const bench = common.createBenchmark(main, { | ||
| 6 | + n: [100, 1000, 1e4], | ||
| 7 | + type: ['sync', 'async'], | ||
| 8 | + }, { | ||
| 9 | + // We don't want to test the reporter here | ||
| 10 | + flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'], | ||
| 11 | + }); | ||
| 12 | + | ||
| 13 | + async function run(n, type) { | ||
| 14 | + const promises = new Array(n); | ||
| 15 | + | ||
| 16 | + // eslint-disable-next-line no-unused-vars | ||
| 17 | + let avoidV8Optimization; | ||
| 18 | + | ||
| 19 | + switch (type) { | ||
| 20 | + case 'sync': { | ||
| 21 | + for (let i = 0; i < n; i++) { | ||
| 22 | + promises[i] = it(`${i}`, () => { | ||
| 23 | + avoidV8Optimization = i; | ||
| 24 | + }); | ||
| 25 | + } | ||
| 26 | + break; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + case 'async': | ||
| 30 | + for (let i = 0; i < n; i++) { | ||
| 31 | + promises[i] = it(`${i}`, async () => { | ||
| 32 | + avoidV8Optimization = i; | ||
| 33 | + }); | ||
| 34 | + } | ||
| 35 | + break; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + await Promise.all(promises); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + function main({ n, type }) { | ||
| 42 | + bench.start(); | ||
| 43 | + run(n, type).then(() => { | ||
| 44 | + bench.end(n); | ||
| 45 | + }); | ||
| 46 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,46 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const { it } = require('node:test'); | ||
| 4 | + | ||
| 5 | + | ||
| 6 | + const bench = common.createBenchmark(main, { | ||
| 7 | + n: [100, 1000, 1e4], | ||
| 8 | + type: ['sync', 'async'], | ||
| 9 | + }, { | ||
| 10 | + // We don't want to test the reporter here | ||
| 11 | + flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'], | ||
| 12 | + }); | ||
| 13 | + | ||
| 14 | + async function run(n, type) { | ||
| 15 | + // eslint-disable-next-line no-unused-vars | ||
| 16 | + let avoidV8Optimization; | ||
| 17 | + | ||
| 18 | + const promises = new Array(n); | ||
| 19 | + switch (type) { | ||
| 20 | + case 'sync': { | ||
| 21 | + for (let i = 0; i < n; i++) { | ||
| 22 | + await it(`${i}`, () => { | ||
| 23 | + avoidV8Optimization = i; | ||
| 24 | + }); | ||
| 25 | + } | ||
| 26 | + break; | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + case 'async': | ||
| 30 | + for (let i = 0; i < n; i++) { | ||
| 31 | + await it(`${i}`, async () => { | ||
| 32 | + avoidV8Optimization = i; | ||
| 33 | + }); | ||
| 34 | + } | ||
| 35 | + break; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + await Promise.all(promises); | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + function main({ n }) { | ||
| 42 | + bench.start(); | ||
| 43 | + run(n).then(() => { | ||
| 44 | + bench.end(n); | ||
| 45 | + }); | ||
| 46 | + } | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,65 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common'); | ||
| 3 | + const { finished } = require('node:stream/promises'); | ||
| 4 | + | ||
| 5 | + const reporter = require('../fixtures/empty-test-reporter'); | ||
| 6 | + | ||
| 7 | + const { describe, it } = require('node:test'); | ||
| 8 | + | ||
| 9 | + const bench = common.createBenchmark(main, { | ||
| 10 | + numberOfSuites: [10, 100], | ||
| 11 | + testsPerSuite: [10, 100, 1000], | ||
| 12 | + testType: ['sync', 'async'], | ||
| 13 | + concurrency: ['yes', 'no'], | ||
| 14 | + }, { | ||
| 15 | + // We don't want to test the reporter here | ||
| 16 | + flags: ['--test-reporter=./benchmark/fixtures/empty-test-reporter.js'], | ||
| 17 | + }); | ||
| 18 | + | ||
| 19 | + async function run({ numberOfSuites, testsPerSuite, testType, concurrency }) { | ||
| 20 | + concurrency = concurrency === 'yes'; | ||
| 21 | + | ||
| 22 | + // eslint-disable-next-line no-unused-vars | ||
| 23 | + let avoidV8Optimization; | ||
| 24 | + | ||
| 25 | + switch (testType) { | ||
| 26 | + case 'sync': { | ||
| 27 | + for (let i = 0; i < numberOfSuites; i++) { | ||
| 28 | + describe(`${i}`, { concurrency }, () => { | ||
| 29 | + for (let j = 0; j < testsPerSuite; j++) { | ||
| 30 | + it(`${j}`, () => { | ||
| 31 | + avoidV8Optimization = i; | ||
| 32 | + }); | ||
| 33 | + } | ||
| 34 | + }); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + break; | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + case 'async': { | ||
| 41 | + for (let i = 0; i < numberOfSuites; i++) { | ||
| 42 | + describe(`${i}`, { concurrency }, () => { | ||
| 43 | + for (let j = 0; j < testsPerSuite; j++) { | ||
| 44 | + it(`${j}`, async () => { | ||
| 45 | + avoidV8Optimization = i; | ||
| 46 | + }); | ||
| 47 | + } | ||
| 48 | + }); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + break; | ||
| 52 | + } | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + await finished(reporter); | ||
| 56 | + | ||
| 57 | + return numberOfSuites * testsPerSuite; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + function main(params) { | ||
| 61 | + bench.start(); | ||
| 62 | + run(params).then((ops) => { | ||
| 63 | + bench.end(ops); | ||
| 64 | + }); | ||
| 65 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments