Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/leaysgur/workers-benchmark
https://github.com/leaysgur/workers-benchmark
Last synced: 24 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/leaysgur/workers-benchmark
- Owner: leaysgur
- Created: 2022-02-24T04:59:01.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-03-14T23:15:28.000Z (over 2 years ago)
- Last Synced: 2024-04-15T07:12:07.144Z (7 months ago)
- Language: Rust
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Workers benchmark
Deploy minimum worker code for JavaScript and Rust(wasm) and compare them.
Original code are generated by
- `wrangler generate`
- `wrangler generate type=rust`and align implementation details.
## Code
### javascript
```javascript
addEventListener("fetch", (ev) => {
ev.respondWith(handleEvent(ev))
})async function handleEvent() {
return new Response("Hello worker!");
}
```### rust
```rust
use worker::*;#[event(fetch)]
pub async fn main(_req: Request, _env: Env, _ctx: worker::Context) -> Result {
Response::ok("Hello worker!")
}
```## Size
### javascript
```
└── [ 147] index.js
```### rust
```
├── [ 71] index.js
└── [ ] worker
├── [ 15K] index_bg.mjs
├── [337K] index_bg.wasm
└── [ 182] shim.mjs
```## Performance
By `autocannon -c 5 -d 5 URL`.
### javascript
```
┌─────────┬──────┬───────┬───────┬───────┬──────────┬─────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼───────┼───────┼───────┼──────────┼─────────┼────────┤
│ Latency │ 9 ms │ 11 ms │ 21 ms │ 25 ms │ 12.31 ms │ 7.34 ms │ 262 ms │
└─────────┴──────┴───────┴───────┴───────┴──────────┴─────────┴────────┘
┌───────────┬────────┬────────┬────────┬────────┬────────┬─────────┬────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼────────┼────────┼────────┼────────┼────────┼─────────┼────────┤
│ Req/Sec │ 372 │ 372 │ 393 │ 408 │ 390 │ 14.33 │ 372 │
├───────────┼────────┼────────┼────────┼────────┼────────┼─────────┼────────┤
│ Bytes/Sec │ 273 kB │ 273 kB │ 289 kB │ 300 kB │ 286 kB │ 10.5 kB │ 273 kB │
└───────────┴────────┴────────┴────────┴────────┴────────┴─────────┴────────┘Req/Bytes counts sampled once per second.
# of samples: 52k requests in 5.05s, 1.43 MB read
```### rust
```
┌─────────┬──────┬───────┬───────┬───────┬──────────┬─────────┬────────┐
│ Stat │ 2.5% │ 50% │ 97.5% │ 99% │ Avg │ Stdev │ Max │
├─────────┼──────┼───────┼───────┼───────┼──────────┼─────────┼────────┤
│ Latency │ 9 ms │ 12 ms │ 24 ms │ 29 ms │ 13.02 ms │ 9.67 ms │ 374 ms │
└─────────┴──────┴───────┴───────┴───────┴──────────┴─────────┴────────┘
┌───────────┬────────┬────────┬────────┬────────┬────────┬─────────┬────────┐
│ Stat │ 1% │ 2.5% │ 50% │ 97.5% │ Avg │ Stdev │ Min │
├───────────┼────────┼────────┼────────┼────────┼────────┼─────────┼────────┤
│ Req/Sec │ 323 │ 323 │ 379 │ 387 │ 369.2 │ 23.35 │ 323 │
├───────────┼────────┼────────┼────────┼────────┼────────┼─────────┼────────┤
│ Bytes/Sec │ 233 kB │ 233 kB │ 273 kB │ 279 kB │ 266 kB │ 16.8 kB │ 232 kB │
└───────────┴────────┴────────┴────────┴────────┴────────┴─────────┴────────┘Req/Bytes counts sampled once per second.
# of samples: 52k requests in 5.04s, 1.33 MB read
```