Skip to content

Commit

Permalink
fix: update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
GrosSacASac committed Nov 30, 2022
1 parent 8611948 commit d6f7b77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
18 changes: 18 additions & 0 deletions benchmark/2022-11-30-i5-9600k.txt
Original file line number Diff line number Diff line change
@@ -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
14 changes: 6 additions & 8 deletions benchmark/index.js
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -20,7 +18,7 @@ const calls = {
end: 0,
};

const start = Date.now();
const start = performance.now();

parser.initWithBoundary(customBoundary);
parser.on('data', ({ name }) => {
Expand All @@ -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`);
Expand All @@ -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,
});
Expand Down

0 comments on commit d6f7b77

Please sign in to comment.