Skip to content

Commit 2738e17

Browse files
committed
update bench
1 parent 57a7cec commit 2738e17

File tree

2 files changed

+61
-53
lines changed

2 files changed

+61
-53
lines changed

README.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
<img src="logo.png" width="400px" />
44
<br /><br />
55

6-
[![Version][v-badge-url]][npm-url] [![Coverage][cov-img]][cov-url] [![Github actions][gh-actions-img]][github-actions] [![Downloads][dl-badge-url]][npm-url]
6+
[![Version][v-badge-url]][npm-url] [![Coverage][cov-img]][cov-url]
7+
[![Github actions][gh-actions-img]][github-actions]
8+
[![Downloads][dl-badge-url]][npm-url]
79

810
</div>
911
<br />
@@ -18,7 +20,7 @@ Check out [deno-libs/parsec](https://github.com/deno-libs/parsec) for Deno port.
1820
- 📦 tiny package size (8KB dist size)
1921
- 🔥 no dependencies
2022
-[tinyhttp](https://github.com/tinyhttp/tinyhttp) and Express support
21-
-30% faster than body-parser
23+
-40% faster than body-parser and 20x faster than formidable
2224

2325
## Install
2426

@@ -51,7 +53,8 @@ const server = createServer(async (req: ReqWithBody, res) => {
5153

5254
### What is "parsec"?
5355

54-
The parsec is a unit of length used to measure large distances to astronomical objects outside the Solar System.
56+
The parsec is a unit of length used to measure large distances to astronomical
57+
objects outside the Solar System.
5558

5659
[v-badge-url]: https://img.shields.io/npm/v/milliparsec.svg?style=for-the-badge&color=25608B&logo=npm&label=
5760
[npm-url]: https://www.npmjs.com/package/milliparsec

bench/index.md

Lines changed: 55 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ conditions.
77

88
## Environment
99

10-
- Node.js 22.3.0
10+
- Node.js 22.3.1
1111
- System: macOS Sequoia 15.3.1 / Darwin 24.3.0 arm64 kernel
1212
- CPU: Apple M2 (8) @ 3.50 GHz
1313
- Machine: MacBook Air (M2, 2022)
@@ -25,40 +25,45 @@ autocannon -b '{"a":1}' -H "Content-Type=application/json" localhost:3002 # or 3
2525
body-parser result:
2626

2727
```
28-
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────
29-
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max
30-
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────
31-
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0.01 ms │ 0.91 ms │ 272 ms │
32-
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────
33-
┌───────────┬─────────┬─────────┬─────────┬────────┬───────────┬──────────┬─────────┐
34-
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
35-
├───────────┼─────────┼─────────┼─────────┼────────┼───────────┼──────────┼─────────┤
36-
│ Req/Sec │ 30,76730,76741,34344,191 │ 39,307.644,333.3330,762
37-
├───────────┼─────────┼─────────┼─────────┼────────┼───────────┼──────────┼─────────┤
38-
│ Bytes/Sec │ 3.97 MB │ 3.97 MB │ 5.33 MB │ 5.7 MB │ 5.07 MB │ 560 kB │ 3.97 MB │
39-
└───────────┴─────────┴─────────┴─────────┴────────┴───────────┴──────────┴─────────┘
28+
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
29+
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
30+
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
31+
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0.01 ms │ 0.12 ms │ 22 ms │
32+
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
33+
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬─────────┐
34+
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
35+
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼─────────┤
36+
│ Req/Sec │ 54,59154,59161,75963,871 │ 61,436.82,478.3954,589
37+
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼─────────┤
38+
│ Bytes/Sec │ 7.05 MB │ 7.05 MB │ 7.97 MB │ 8.24 MB │ 7.93 MB │ 319 kB │ 7.04 MB │
39+
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴─────────┘
4040
4141
Req/Bytes counts sampled once per second.
42-
# of samples: 11
42+
# of samples: 10
4343
44-
432k requests in 11.03s, 55.8 MB read
44+
614k requests in 10.01s, 79.3 MB read
4545
```
4646

4747
milliparsec result:
4848

4949
```
50-
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬────────┐
51-
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
52-
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼────────┤
53-
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0.01 ms │ 0.68 ms │ 255 ms │
54-
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴────────┘
55-
┌───────────┬─────────┬─────────┬─────────┬─────────┬──────────┬──────────┬─────────┐
56-
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
57-
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼─────────┤
58-
│ Req/Sec │ 46,047 │ 46,047 │ 59,391 │ 64,255 │ 58,285.1 │ 4,625.15 │ 46,025 │
59-
├───────────┼─────────┼─────────┼─────────┼─────────┼──────────┼──────────┼─────────┤
60-
│ Bytes/Sec │ 5.62 MB │ 5.62 MB │ 7.25 MB │ 7.84 MB │ 7.11 MB │ 565 kB │ 5.62 MB │
61-
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴─────────┘
50+
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
51+
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
52+
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
53+
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0.01 ms │ 0.04 ms │ 11 ms │
54+
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
55+
┌───────────┬─────────┬─────────┬─────────┬─────────┬───────────┬──────────┬─────────┐
56+
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
57+
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
58+
│ Req/Sec │ 79,999 │ 79,999 │ 88,127 │ 88,767 │ 87,095.28 │ 2,370.01 │ 79,966 │
59+
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
60+
│ Bytes/Sec │ 9.76 MB │ 9.76 MB │ 10.7 MB │ 10.8 MB │ 10.6 MB │ 289 kB │ 9.76 MB │
61+
└───────────┴─────────┴─────────┴─────────┴─────────┴───────────┴──────────┴─────────┘
62+
63+
Req/Bytes counts sampled once per second.
64+
# of samples: 11
65+
66+
958k requests in 11.01s, 117 MB read
6267
6368
Req/Bytes counts sampled once per second.
6469
# of samples: 11
@@ -68,7 +73,7 @@ Req/Bytes counts sampled once per second.
6873

6974
### Verdict
7075

71-
milliparsec, on average, is ~30-40% faster.
76+
milliparsec, on average, is ~40% faster.
7277

7378
## Multipart with files
7479

@@ -83,47 +88,47 @@ autocannon -m POST --form '{ "file": { "type": "file", "path": "./file.txt" }
8388
formidable result:
8489

8590
```
86-
┌─────────┬──────┬──────┬───────┬───────┬─────────┬─────────┬───────┐
87-
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max
88-
├─────────┼──────┼──────┼───────┼───────┼─────────┼─────────┼───────┤
89-
│ Latency │ 1 ms │ 10 ms │ 29 ms │ 33 ms │ 11.1 ms │ 9.48 ms │ 261 ms │
90-
└─────────┴──────┴──────┴───────┴───────┴─────────┴─────────┴───────┘
91-
┌───────────┬───────┬───────┬────────┬────────┬────────┬───────────────┐
92-
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
93-
├───────────┼───────┼───────┼────────┼────────┼────────┼───────────────┤
94-
│ Req/Sec │ 500 │ 500 │ 6302,339860.9526.44500
95-
├───────────┼───────┼───────┼────────┼────────┼────────┼───────────────┤
96-
│ Bytes/Sec │ 99 kB │ 99 kB │ 125 kB │ 463 kB │ 170 kB │ 104 kB │ 99 kB │
97-
└───────────┴───────┴───────┴────────┴────────┴────────┴───────────────┘
91+
┌─────────┬──────┬──────┬───────┬───────┬─────────┬─────────┬───────┐
92+
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
93+
├─────────┼──────┼──────┼───────┼───────┼─────────┼─────────┼───────┤
94+
│ Latency │ 1 ms │ 5 ms │ 19 ms │ 26 ms │ 6.63 ms │ 5.86 ms │ 54 ms │
95+
└─────────┴──────┴──────┴───────┴───────┴─────────┴─────────┴───────┘
96+
┌───────────┬───────┬───────┬────────┬────────┬────────┬──────────┬────────┐
97+
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min
98+
├───────────┼───────┼───────┼────────┼────────┼────────┼──────────┼────────┤
99+
│ Req/Sec │ 530 │ 530 │ 7754,5951,4041,179.32530
100+
├───────────┼───────┼───────┼────────┼────────┼────────┼──────────┼────────┤
101+
│ Bytes/Sec │ 105 kB │ 105 kB │ 153 kB │ 910 kB │ 278 kB │ 233 kB │ 105 kB │
102+
└───────────┴───────┴───────┴────────┴────────┴────────┴──────────┴────────┘
98103
99104
Req/Bytes counts sampled once per second.
100105
# of samples: 10
101106
102-
9k requests in 10.03s, 1.7 MB read
107+
14k requests in 10.02s, 2.78 MB read
103108
```
104109

105110
milliparsec result:
106111

107112
```
108-
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────
109-
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max
110-
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────
111-
│ Latency │ 0 ms │ 0 ms │ 1 ms │ 1 ms │ 0.09 ms │ 1.39 ms │ 267 ms │
112-
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────
113+
┌─────────┬──────┬──────┬───────┬──────┬─────────┬─────────┬───────┐
114+
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
115+
├─────────┼──────┼──────┼───────┼──────┼─────────┼─────────┼───────┤
116+
│ Latency │ 0 ms │ 0 ms │ 0 ms │ 0 ms │ 0.02 ms │ 0.19 ms │ 20 ms │
117+
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
113118
┌───────────┬─────────┬─────────┬─────────┬─────────┬───────────┬──────────┬─────────┐
114119
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
115120
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
116-
│ Req/Sec │ 8,543 │ 8,543 │ 17,77518,39916,962.552,697.578,537
121+
│ Req/Sec │ 24,063 │ 24,063 │ 29,72730,86329,263.281,758.9424,051
117122
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
118-
│ Bytes/Sec │ 1.69 MB │ 1.69 MB │ 3.52 MB │ 3.64 MB │ 3.36 MB │ 534 kB │ 1.69 MB │
123+
│ Bytes/Sec │ 4.76 MB │ 4.76 MB │ 5.89 MB │ 6.11 MB │ 5.79 MB │ 348 kB │ 4.76 MB │
119124
└───────────┴─────────┴─────────┴─────────┴─────────┴───────────┴──────────┴─────────┘
120125
121126
Req/Bytes counts sampled once per second.
122127
# of samples: 11
123128
124-
187k requests in 11.03s, 36.9 MB read
129+
322k requests in 11.01s, 63.7 MB read
125130
```
126131

127132
### Verdict
128133

129-
milliparsec, on average, is 10-20x faster.
134+
milliparsec, on average, is ~20x faster.

0 commit comments

Comments
 (0)