Skip to content

Commit

Permalink
upload benchmark code
Browse files Browse the repository at this point in the history
  • Loading branch information
hans00 committed Dec 1, 2019
1 parent 047018d commit e67eab6
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ fastWS
[![Node version](https://img.shields.io/node/v/fast-ws.svg)](https://www.npmjs.com/package/fast-ws)
[![GitHub Action](https://github.com/hans00/fastWS/workflows/publish%20package/badge.svg)](https://github.com/hans00/fastWS)

Simple Node.js server based on uWebSockets
Simple Node.js server based on uWebSockets.

[Benchmark result](benchmark/README.md)

---

Expand Down
6 changes: 3 additions & 3 deletions BENCHMARK.md → benchmark/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ Transfer/sec: 1.26MB
# Dynamic with URL parameter

```sh
wrk -c 1k -t 10 -d 10s http://<IP>:3000/param/test
wrk -c 1k -t 10 -d 10s http://<IP>:3000/hello/test
```

## Express

```
Running 10s test @ http://<IP>:3000/param/test
Running 10s test @ http://<IP>:3000/hello/test
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 102.97ms 101.94ms 1.35s 97.42%
Expand All @@ -90,7 +90,7 @@ Transfer/sec: 1.19MB
## This Project

```
Running 10s test @ http://<IP>:3000/param/test
Running 10s test @ http://<IP>:3000/hello/test
10 threads and 1000 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 25.17ms 12.54ms 493.42ms 99.29%
Expand Down
23 changes: 23 additions & 0 deletions benchmark/express.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
const http = require('http')
const WebSocket = require('ws')

const app = express()
const server = http.createServer(app)

const wss = new WebSocket.Server({ server, path: '/ws' })

wss.on('connection', ws => {
ws.on('message', data => {
ws.send(data)
})
})

app.get('/hello/:name', (req, res) => {
res.end(`Hello ${req.params.name}`)
})

app.use('/', express.static('static'))

server.listen(3000, () => {
console.log('Listen on 3000')
})
17 changes: 17 additions & 0 deletions benchmark/fast-ws.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fastWS = require('fast-ws/server')

const app = new fastWS()

app.ws('/ws', ws => null, {
protocol: 'echo'
})

app.get('/hello/:name', (req, res, { name }) => {
res.end(`Hello ${name}`)
})

app.serve('/')

app.listen(3000, () => {
console.log('Listen on 3000')
})

0 comments on commit e67eab6

Please sign in to comment.