diff --git a/benchmarks/_results/Busboy_comparison-busboy-Node_20.json b/benchmarks/_results/Busboy_comparison-busboy-Node_20.json index 2b5808f..16d8a5b 100644 --- a/benchmarks/_results/Busboy_comparison-busboy-Node_20.json +++ b/benchmarks/_results/Busboy_comparison-busboy-Node_20.json @@ -5,6 +5,6 @@ "benchmarkCycles": 500, "benchmarkCycleSamples": 50, "warmupCycles": 50, - "meanTimeNs": 271603.6766274161, - "meanTimeMs": 0.2716036766274161 + "meanTimeNs": 259789.77117937893, + "meanTimeMs": 0.25978977117937896 } \ No newline at end of file diff --git a/benchmarks/_results/Busboy_comparison-fastify-busboy-Node_20.json b/benchmarks/_results/Busboy_comparison-fastify-busboy-Node_20.json index 912aaf7..fa22c30 100644 --- a/benchmarks/_results/Busboy_comparison-fastify-busboy-Node_20.json +++ b/benchmarks/_results/Busboy_comparison-fastify-busboy-Node_20.json @@ -5,6 +5,6 @@ "benchmarkCycles": 500, "benchmarkCycleSamples": 50, "warmupCycles": 50, - "meanTimeNs": 192632.5067214754, - "meanTimeMs": 0.1926325067214754 + "meanTimeNs": 188173.65372222223, + "meanTimeMs": 0.18817365372222222 } \ No newline at end of file diff --git a/benchmarks/_results/Busboy_comparison-multipasta-Node_20.json b/benchmarks/_results/Busboy_comparison-multipasta-Node_20.json index f7efc1a..80d3d7b 100644 --- a/benchmarks/_results/Busboy_comparison-multipasta-Node_20.json +++ b/benchmarks/_results/Busboy_comparison-multipasta-Node_20.json @@ -5,6 +5,6 @@ "benchmarkCycles": 500, "benchmarkCycleSamples": 50, "warmupCycles": 50, - "meanTimeNs": 79651.12307008775, - "meanTimeMs": 0.07965112307008775 + "meanTimeNs": 67089.49805620349, + "meanTimeMs": 0.0670894980562035 } \ No newline at end of file diff --git a/benchmarks/_results/results.md b/benchmarks/_results/results.md index 31b684a..004e4d5 100644 --- a/benchmarks/_results/results.md +++ b/benchmarks/_results/results.md @@ -1,7 +1,7 @@ | Node | Option | Msecs/op | Ops/sec | V8 | | ------ | -------------- | -------------- | --------- | --------------------- | -| 20.9.0 | multipasta | 0.079651 msecs | 12554.751 | V8 11.3.244.8-node.16 | -| 20.9.0 | fastify-busboy | 0.192633 msecs | 5191.232 | V8 11.3.244.8-node.16 | -| 20.9.0 | busboy | 0.271604 msecs | 3681.835 | V8 11.3.244.8-node.16 | +| 20.9.0 | multipasta | 0.076734 msecs | 13032.031 | V8 11.3.244.8-node.16 | +| 20.9.0 | fastify-busboy | 0.190665 msecs | 5244.802 | V8 11.3.244.8-node.16 | +| 20.9.0 | busboy | 0.266504 msecs | 3752.289 | V8 11.3.244.8-node.16 | **Specs**: Coreā„¢ i9-9880H (2.3 GHz) \ No newline at end of file diff --git a/benchmarks/busboy/contestants/busboy.js b/benchmarks/busboy/contestants/busboy.js index a72e04b..130496c 100644 --- a/benchmarks/busboy/contestants/busboy.js +++ b/benchmarks/busboy/contestants/busboy.js @@ -10,22 +10,25 @@ function process () { } }) let processedSize = 0 + let partCount = 0 return new Promise((resolve, reject) => { busboy.on('file', (field, file, filename, encoding, mimetype) => { + partCount++ file.on('data', (data) => { processedSize += data.length }) }) busboy.on('field', (field, value) => { processedSize += value.length + partCount++ }) busboy.on('error', function (err) { reject(err) }) busboy.on('finish', function () { - resolve(processedSize) + resolve([processedSize, partCount]) }) for (const buffer of buffers) { busboy.write(buffer, () => { }) } diff --git a/benchmarks/busboy/contestants/fastify-busboy.js b/benchmarks/busboy/contestants/fastify-busboy.js index 376d164..64be2a8 100644 --- a/benchmarks/busboy/contestants/fastify-busboy.js +++ b/benchmarks/busboy/contestants/fastify-busboy.js @@ -11,22 +11,25 @@ function process () { }) let processedSize = 0 + let partCount = 0 return new Promise((resolve, reject) => { busboy.on('file', (field, file, filename, encoding, mimetype) => { + partCount++ file.on('data', (data) => { processedSize += data.length }) }) busboy.on('field', (field, value) => { processedSize += value.length + partCount++ }) busboy.on('error', function (err) { reject(err) }) busboy.on('finish', function () { - resolve(processedSize) + resolve([processedSize, partCount]) }) for (const buffer of buffers) { busboy.write(buffer, () => { }) } diff --git a/benchmarks/busboy/contestants/multipasta.js b/benchmarks/busboy/contestants/multipasta.js index c56e642..d0e2866 100644 --- a/benchmarks/busboy/contestants/multipasta.js +++ b/benchmarks/busboy/contestants/multipasta.js @@ -6,14 +6,17 @@ const { buffers, boundary } = require('../data') function process () { return new Promise((resolve, reject) => { let processedSize = 0 + let partCount = 0 const parser = MP.make({ headers: { 'content-type': 'multipart/form-data; boundary=' + boundary }, onField (_info, value) { processedSize += value.length + partCount++ }, onFile (_info) { + partCount++ return function (chunk) { if (chunk !== null) { processedSize += chunk.length @@ -24,7 +27,7 @@ function process () { reject(err) }, onDone () { - resolve(processedSize) + resolve([processedSize, partCount]) } }) for (const buffer of buffers) { parser.write(buffer) } diff --git a/benchmarks/busboy/validator.js b/benchmarks/busboy/validator.js index c6512dd..19953b4 100644 --- a/benchmarks/busboy/validator.js +++ b/benchmarks/busboy/validator.js @@ -6,8 +6,9 @@ const { fileContent, fileCount, fieldContent, fieldCount } = require('./data') const EXPECTED_RESULT = (fileContent.length * fileCount) + (fieldContent.length * fieldCount) async function validateAccuracy (actualResultPromise) { - const result = await actualResultPromise + const [result, parts] = await actualResultPromise validateEqual(result, EXPECTED_RESULT) + validateEqual(parts, fileCount + fieldCount) } module.exports = { diff --git a/package.json b/package.json index f1cdc7e..8711ce0 100644 --- a/package.json +++ b/package.json @@ -38,7 +38,7 @@ "devDependencies": { "@types/node": "^20.1.0", "busboy": "^1.0.0", - "multipasta": "^0.1.12", + "multipasta": "^0.1.15", "photofinish": "^1.8.0", "snazzy": "^9.0.0", "standard": "^17.0.0",