Skip to content

Commit

Permalink
Add benchmark tests results in Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
allevo committed Nov 21, 2023
1 parent 4918219 commit 300c9dc
Show file tree
Hide file tree
Showing 15 changed files with 31,538 additions and 23 deletions.
72 changes: 72 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,78 @@ This library exports the following functions:
- `des.deserializeFloat32()`: deserializes float 32bit.
- `ser.getBuffer()`: returns the serialized buffer.

## Benchmarks

We created 3 different benchmarks to compare the performance of SeqProto with JSON and Avro.

### Isolated benchmark

You can run the benchmarks with the following command:
```sh
npm run benchmark:serdes
```

Serialization / Deserialization:
| name | ops | margin | percentSlower |
| -------- | ------- | -------- | ------- |
| seqproto | 29764 | 0.72 | 0 |
| protobuf | 13698 | 0.19 | 53.98 |
| avro | 24204 | 0.14 | 18.68 |
| cbor | 803 | 0.22 | 97.3 |
| cborx | 9707 | 0.32 | 67.39 |
| msgpack | 6857 | 0.06 | 76.96 |
| msgpackr | 10449 | 0.27 | 64.89 |
| JSON | 14434 | 0.07 | 51.51 |

### Http benchmark

You can run the benchmarks using 2 shells.

1.
```sh
cd bechmarks/e2e
pnpm install
pnpm start
```
2.
```sh
cd bechmarks/e2e
pnpm run autocannon:json
pnpm run autocannon:seqproto
pnpm run autocannon:avro
```

| type | req (in 10s) | Avg req/sec | Avg Bytes/Sec | Avg Latency (ms) |
| -------- | ---- | --------- | ---- | ---- |
| JSON | 164k | 14892 | 275 | 0.11 |
| SeqProto | 269k | 26865.6 | 321 | 0.01 |
| Avro | 197k | 17926.55 | 169 | 0.04 |

### e2e benchmark

You can run the benchmarks with the following command:
```sh
cd bechmarks/e2e
pnpm install
pnpm start
```
And go to http://localhost:3000/public/index.html.

| iteration | parallelism | type | ms |
| -------- | ------- | -------- | ------- |
| 10 | 1 | JSON | 30.69999998807907 |
| 10 | 1 | SeqProto | 25.600000023841858 |
| 10 | 1 | Avro | 30.399999976158142 |
| 100 | 1 | JSON | 108.80000001192093 |
| 100 | 1 | SeqProto | 96.80000001192093 |
| 100 | 1 | Avro | 96 |
| 100 | 3 | JSON | 162.10000002384186 |
| 100 | 3 | SeqProto | 152.4000000357628 |
| 100 | 3 | Avro | 167.5 |
| 100 | 6 | JSON | 277.19999998807907 |
| 100 | 6 | SeqProto | 263.30000001192093 |
| 100 | 6 | Avro | 308.19999998807907 |

## Contributing

Contributions are welcome! Please open an issue if you have any ideas for improvement or found a bug.
Expand Down
45 changes: 45 additions & 0 deletions benchmarks/e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "seqproto-benchmarks-e2e",
"version": "0.0.1",
"type": "module",
"description": "",
"scripts": {
"start": "node --import tsx src/index.ts",
"autocannon:json": "npx autocannon 'http://localhost:3000/todos'",
"autocannon:seqproto": "npx autocannon -H 'accept=application/seqproto' 'http://localhost:3000/todos'",
"autocannon:avro": "autocannon -H 'accept=application/avro' 'http://localhost:3000/todos'"
},
"author": {
"name": "Tommaso Allevi",
"email": "[email protected]",
"url": "https://github.com/allevo",
"author": true
},
"engines": {
"node": ">= 20.0.0"
},
"devDependencies": {
"@msgpack/msgpack": "3.0.0-beta2",
"@types/node": "=20.8.0",
"autocannon": "^7.12.0",
"avro-js": "^1.11.3",
"avsc": "^5.7.7",
"benny": "^3.7.1",
"browserify": "^17.0.0",
"cbor": "^9.0.1",
"cbor-x": "^1.5.4",
"fast-json-stringify": "^5.9.1",
"lodash": "^4.17.21",
"msgpackr": "^1.9.9",
"protobufjs": "^7.2.5",
"ts-standard": "^12.0.2",
"tsx": "^3.14.0",
"typescript": "^5.2.2",
"undici-types": "^5.27.2"
},
"dependencies": {
"@fastify/static": "^6.12.0",
"fastify": "^4.24.3",
"seqproto": "link:../.."
}
}
Loading

0 comments on commit 300c9dc

Please sign in to comment.