Skip to content

Commit d6f7b77

Browse files
committed
fix: update benchmarks
1 parent 8611948 commit d6f7b77

File tree

2 files changed

+24
-8
lines changed

2 files changed

+24
-8
lines changed

benchmark/2022-11-30-i5-9600k.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
npm run bench
2+
3+
4+
> node benchmark
5+
6+
4132.23 mb/sec
7+
PS C:\files\formidable> node -v
8+
v18.0.0
9+
10+
npm run bench
11+
12+
13+
> node benchmark
14+
15+
3952.57 mb/sec
16+
17+
PS C:\files\formidable> node -v
18+
v19.2.0

benchmark/index.js

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
1-
'use strict';
1+
import assert from "node:assert";
2+
import MultipartParser from '../src/parsers/Multipart.js';
23

3-
const assert = require('assert');
4-
5-
const MultipartParser = require('../src/parsers/Multipart');
64

75
const parser = new MultipartParser();
86
const customBoundary = '-----------------------------168072824752491622650073';
@@ -20,7 +18,7 @@ const calls = {
2018
end: 0,
2119
};
2220

23-
const start = Date.now();
21+
const start = performance.now();
2422

2523
parser.initWithBoundary(customBoundary);
2624
parser.on('data', ({ name }) => {
@@ -29,7 +27,7 @@ parser.on('data', ({ name }) => {
2927

3028
parser.write(buf);
3129

32-
const duration = Date.now() - start;
30+
const duration = performance.now() - start;
3331
const mbPerSec = (mb / (duration / 1000)).toFixed(2);
3432

3533
console.log(`${mbPerSec} mb/sec`);
@@ -51,10 +49,10 @@ process.on('exit', () => {
5149
assert.deepStrictEqual(calls, {
5250
partBegin: 1,
5351
headerField: 1,
54-
headerValue: 2,
52+
headerValue: 1,
5553
headerEnd: 1,
5654
headersEnd: 1,
57-
partData: 2,
55+
partData: 1,
5856
partEnd: 1,
5957
end: 1,
6058
});

0 commit comments

Comments
 (0)