Skip to content

Commit 521982b

Browse files
v1rtlclaude
andcommitted
remove tsx, use native Node.js TypeScript support
- Remove tsx dependency, use `node --test` instead - Update imports to use .ts extensions - Add rewriteRelativeImportExtensions to tsconfig for build - Replace autocannon with oha for benchmarks - Update benchmark results Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent c8d6518 commit 521982b

File tree

10 files changed

+264
-575
lines changed

10 files changed

+264
-575
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Check out [deno-libs/parsec](https://github.com/deno-libs/parsec) for Deno port.
2020
- 📦 tiny package size (8KB dist size)
2121
- 🔥 no dependencies
2222
-[tinyhttp](https://github.com/tinyhttp/tinyhttp) and Express support
23-
-40% faster than body-parser and 20x faster than formidable
23+
-~10% faster than body-parser, ~36% faster than formidable
2424

2525
## Install
2626

bench/index.md

Lines changed: 63 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,128 +7,110 @@ conditions.
77

88
## Environment
99

10-
- Node.js 22.3.1
11-
- System: macOS Sequoia 15.3.1 / Darwin 24.3.0 arm64 kernel
12-
- CPU: Apple M2 (8) @ 3.50 GHz
13-
- Machine: MacBook Air (M2, 2022)
10+
- Node.js v24.4.0
11+
- System: Linux 6.18.5-arch1-1 x86_64
12+
- CPU: 13th Gen Intel Core i9-13900H
1413

1514
## JSON parsing
1615

1716
### Benchmark command:
1817

1918
```sh
20-
autocannon -m POST -b '{"a":1}' -H "Content-Type=application/json" localhost:3002 # or 3003
19+
oha -m POST -d '{"a":1}' -H "Content-Type: application/json" http://localhost:3002 # or 3003
2120
```
2221

2322
### Results
2423

2524
body-parser result:
2625

2726
```
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,591 │ 54,591 │ 61,759 │ 63,871 │ 61,436.8 │ 2,478.39 │ 54,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-
└───────────┴─────────┴─────────┴─────────┴─────────┴──────────┴──────────┴─────────┘
40-
41-
Req/Bytes counts sampled once per second.
42-
# of samples: 10
43-
44-
614k requests in 10.01s, 79.3 MB read
27+
Summary:
28+
Success rate: 100.00%
29+
Total: 60.2458 ms
30+
Slowest: 55.2801 ms
31+
Fastest: 0.5548 ms
32+
Average: 12.0064 ms
33+
Requests/sec: 3319.7335
34+
35+
Response time distribution:
36+
50.00% in 1.3036 ms
37+
75.00% in 31.2024 ms
38+
90.00% in 46.0986 ms
39+
95.00% in 47.2233 ms
40+
99.00% in 52.1532 ms
4541
```
4642

4743
milliparsec result:
4844

4945
```
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
67-
68-
Req/Bytes counts sampled once per second.
69-
# of samples: 11
70-
71-
641k requests in 11.02s, 78.2 MB read
46+
Summary:
47+
Success rate: 100.00%
48+
Total: 54.7949 ms
49+
Slowest: 44.1667 ms
50+
Fastest: 0.6135 ms
51+
Average: 9.5273 ms
52+
Requests/sec: 3649.9779
53+
54+
Response time distribution:
55+
50.00% in 1.1726 ms
56+
75.00% in 17.3265 ms
57+
90.00% in 36.4140 ms
58+
95.00% in 37.4827 ms
59+
99.00% in 43.6290 ms
7260
```
7361

7462
### Verdict
7563

76-
milliparsec, on average, is ~40% faster.
64+
milliparsec, on average, is ~10% faster.
7765

7866
## Multipart with files
7967

8068
### Benchmark command:
8169

8270
```sh
83-
autocannon -m POST --form '{ "file": { "type": "file", "path": "./file.txt" } }' localhost:3004
71+
oha -m POST -D multipart-body.txt -H "Content-Type: multipart/form-data; boundary=boundary" http://localhost:3004 # or 3005
8472
```
8573

8674
### Results
8775

8876
formidable result:
8977

9078
```
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 │ 775 │ 4,595 │ 1,404 │ 1,179.32 │ 530 │
100-
├───────────┼────────┼────────┼────────┼────────┼────────┼──────────┼────────┤
101-
│ Bytes/Sec │ 105 kB │ 105 kB │ 153 kB │ 910 kB │ 278 kB │ 233 kB │ 105 kB │
102-
└───────────┴────────┴────────┴────────┴────────┴────────┴──────────┴────────┘
103-
104-
Req/Bytes counts sampled once per second.
105-
# of samples: 10
106-
107-
14k requests in 10.02s, 2.78 MB read
79+
Summary:
80+
Success rate: 100.00%
81+
Total: 108.3334 ms
82+
Slowest: 71.1838 ms
83+
Fastest: 8.5817 ms
84+
Average: 23.8519 ms
85+
Requests/sec: 1846.1530
86+
87+
Response time distribution:
88+
50.00% in 16.0338 ms
89+
75.00% in 56.2787 ms
90+
90.00% in 56.8965 ms
91+
95.00% in 69.7132 ms
92+
99.00% in 71.0121 ms
10893
```
10994

11095
milliparsec result:
11196

11297
```
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-
└─────────┴──────┴──────┴───────┴──────┴─────────┴─────────┴───────┘
118-
┌───────────┬─────────┬─────────┬─────────┬─────────┬───────────┬──────────┬─────────┐
119-
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
120-
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
121-
│ Req/Sec │ 24,063 │ 24,063 │ 29,727 │ 30,863 │ 29,263.28 │ 1,758.94 │ 24,051 │
122-
├───────────┼─────────┼─────────┼─────────┼─────────┼───────────┼──────────┼─────────┤
123-
│ Bytes/Sec │ 4.76 MB │ 4.76 MB │ 5.89 MB │ 6.11 MB │ 5.79 MB │ 348 kB │ 4.76 MB │
124-
└───────────┴─────────┴─────────┴─────────┴─────────┴───────────┴──────────┴─────────┘
125-
126-
Req/Bytes counts sampled once per second.
127-
# of samples: 11
128-
129-
322k requests in 11.01s, 63.7 MB read
98+
Summary:
99+
Success rate: 100.00%
100+
Total: 79.4623 ms
101+
Slowest: 67.6478 ms
102+
Fastest: 1.6161 ms
103+
Average: 15.9568 ms
104+
Requests/sec: 2516.9155
105+
106+
Response time distribution:
107+
50.00% in 2.9719 ms
108+
75.00% in 24.1332 ms
109+
90.00% in 62.7090 ms
110+
95.00% in 65.4033 ms
111+
99.00% in 67.3112 ms
130112
```
131113

132114
### Verdict
133115

134-
milliparsec, on average, is ~20x faster.
116+
milliparsec, on average, is ~36% faster.

bench/multipart-body.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--boundary
2+
Content-Disposition: form-data; name="file"; filename="file.txt"
3+
Content-Type: text/plain
4+
5+
this is a file that is being sent in a multipart request
6+
--boundary--

bench/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,15 @@
55
"description": "",
66
"main": "index.js",
77
"scripts": {
8-
"bench": "autocannon -m POST -b '{\"a\":1}' -H \"Content-Type=application/json\"",
9-
"bench:multipart": "autocannon -m POST --form '{ \"file\": { \"type\": \"file\", \"path\": \"./file.txt\" } }'"
8+
"bench": "oha -m POST -d '{\"a\":1}' -H \"Content-Type: application/json\"",
9+
"bench:multipart": "oha -m POST -D ./file.txt -H \"Content-Type: multipart/form-data\""
1010
},
1111
"keywords": [],
1212
"author": "",
1313
"license": "ISC",
1414
"devDependencies": {
1515
"@types/body-parser": "^1.19.6",
1616
"@types/formidable": "^3.4.5",
17-
"autocannon": "^8.0.0",
1817
"body-parser": "^2.2.0"
1918
},
2019
"dependencies": {

package.json

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,19 @@
2222
"exports": "./dist/index.js",
2323
"devDependencies": {
2424
"@biomejs/biome": "2.2.2",
25-
"@tinyhttp/app": "^2.4.0",
26-
"@types/express": "^5.0.3",
27-
"@types/node": "^18",
25+
"@tinyhttp/app": "^2.5.2",
26+
"@types/express": "^5.0.6",
27+
"@types/node": "^18.19.130",
2828
"c8": "10.1.2",
29-
"express": "^5.1.0",
29+
"express": "^5.2.1",
3030
"supertest-fetch": "^2.0.0",
31-
"tsx": "^4.19.1",
32-
"typescript": "^5.6.2"
31+
"typescript": "^5.9.3"
3332
},
3433
"files": [
3534
"dist"
3635
],
3736
"scripts": {
38-
"test": "tsx --test test.ts",
37+
"test": "node --test test.ts",
3938
"test:coverage": "c8 --include=src pnpm test",
4039
"test:report": "c8 report --reporter=text-lcov > coverage.lcov",
4140
"build": "tsc -p tsconfig.build.json",

0 commit comments

Comments
 (0)