File tree Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Expand file tree Collapse file tree 2 files changed +24
-8
lines changed Original file line number Diff line number Diff line change 1+ npm run bench
2+
3+ > formidable@3.2.5 bench
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+ > formidable@3.2.5 bench
13+ > node benchmark
14+
15+ 3952.57 mb/sec
16+
17+ PS C:\files\formidable> node -v
18+ v19.2.0
Original file line number Diff line number Diff line change 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
75const parser = new MultipartParser ( ) ;
86const customBoundary = '-----------------------------168072824752491622650073' ;
@@ -20,7 +18,7 @@ const calls = {
2018 end : 0 ,
2119} ;
2220
23- const start = Date . now ( ) ;
21+ const start = performance . now ( ) ;
2422
2523parser . initWithBoundary ( customBoundary ) ;
2624parser . on ( 'data' , ( { name } ) => {
@@ -29,7 +27,7 @@ parser.on('data', ({ name }) => {
2927
3028parser . write ( buf ) ;
3129
32- const duration = Date . now ( ) - start ;
30+ const duration = performance . now ( ) - start ;
3331const mbPerSec = ( mb / ( duration / 1000 ) ) . toFixed ( 2 ) ;
3432
3533console . 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 } ) ;
You can’t perform that action at this time.
0 commit comments