diff --git a/benchmark/2022-11-30-i5-9600k.txt b/benchmark/2022-11-30-i5-9600k.txt new file mode 100644 index 00000000..96fde1c4 --- /dev/null +++ b/benchmark/2022-11-30-i5-9600k.txt @@ -0,0 +1,18 @@ +npm run bench + +> formidable@3.2.5 bench +> node benchmark + +4132.23 mb/sec +PS C:\files\formidable> node -v +v18.0.0 + +npm run bench + +> formidable@3.2.5 bench +> node benchmark + +3952.57 mb/sec + +PS C:\files\formidable> node -v +v19.2.0 diff --git a/benchmark/index.js b/benchmark/index.js index 136bf123..9dbb4c46 100644 --- a/benchmark/index.js +++ b/benchmark/index.js @@ -1,8 +1,6 @@ -'use strict'; +import assert from "node:assert"; +import MultipartParser from '../src/parsers/Multipart.js'; -const assert = require('assert'); - -const MultipartParser = require('../src/parsers/Multipart'); const parser = new MultipartParser(); const customBoundary = '-----------------------------168072824752491622650073'; @@ -20,7 +18,7 @@ const calls = { end: 0, }; -const start = Date.now(); +const start = performance.now(); parser.initWithBoundary(customBoundary); parser.on('data', ({ name }) => { @@ -29,7 +27,7 @@ parser.on('data', ({ name }) => { parser.write(buf); -const duration = Date.now() - start; +const duration = performance.now() - start; const mbPerSec = (mb / (duration / 1000)).toFixed(2); console.log(`${mbPerSec} mb/sec`); @@ -51,10 +49,10 @@ process.on('exit', () => { assert.deepStrictEqual(calls, { partBegin: 1, headerField: 1, - headerValue: 2, + headerValue: 1, headerEnd: 1, headersEnd: 1, - partData: 2, + partData: 1, partEnd: 1, end: 1, });