Skip to content

Commit

Permalink
Fix request parsing in TS benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
Tortoaster committed Dec 19, 2023
1 parent cff3a51 commit d3ccdd6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Nea Benchmarks

```shell
siege -c 4 -b -i -f ../urls.txt
siege -c 4 -b -i -f ../urls.txt -r 10000
```

## Rust / Tokio
Expand Down
10 changes: 5 additions & 5 deletions benchmarks/ts-node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ const server = net.createServer((socket) => {
const requestString = data.toString();

// Basic parsing of the request
const [requestLine, remainder] = requestString.split('\r\n', 2);
const [method, path, version] = requestLine.split(' ');
const [headerLines, body] = requestString.split('\r\n\r\n', 2);
const lines = headerLines.split('\r\n');
const [method, path, version] = lines[0].split(' ');
const headers = new Map<string, string>();
const [headerLines, body] = remainder.split('\r\n\r\n', 2);
for (const line of headerLines.split('\r\n')) {
const [key, value] = line.split(': ');
for (const line of lines.slice(1)) {
const [key, value] = line.split(': ', 2);
headers.set(key, value);
}

Expand Down
3 changes: 1 addition & 2 deletions benchmarks/urls.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
127.0.0.1:8000
127.0.0.1:8000 POST 1,1,2,1,2,2,1,1
127.0.0.1:8000/10 POST 1, 1\n2, 1\n2, 2\n1, 1

0 comments on commit d3ccdd6

Please sign in to comment.