mirror of
https://gitea.invidious.io/iv-org/shard-kemal.git
synced 2024-08-15 00:53:36 +00:00
Add benchmark to Websockets
This commit is contained in:
parent
35d4bd43cc
commit
cdafe54c1d
1 changed files with 41 additions and 0 deletions
|
@ -37,3 +37,44 @@ ws "/" do |socket|
|
|||
end
|
||||
end
|
||||
```
|
||||
|
||||
## Performance
|
||||
|
||||
Thanks to Crystal Kemal has superb performance for Websockets.
|
||||
|
||||
Crystal 0.9.1 with [Kemal]
|
||||
|
||||
```ruby
|
||||
require "kemal"
|
||||
|
||||
ws "/" do |socket|
|
||||
socket.on_message do |message|
|
||||
end
|
||||
end
|
||||
```
|
||||
|
||||
Node.js v4.2.1 with [ws](https://github.com/websockets/ws)
|
||||
|
||||
```js
|
||||
var WebSocketServer = require('ws').Server
|
||||
, wss = new WebSocketServer({ port: 3000 });
|
||||
|
||||
wss.on('connection', function connection(ws) {
|
||||
ws.on('message', function incoming(message) {
|
||||
});
|
||||
|
||||
});
|
||||
```
|
||||
|
||||
[Thor](https://github.com/observing/thor) is used to run the benchmark.
|
||||
|
||||
`thor -A 10000 http://localhost:3000`
|
||||
|
||||
| Platform | CPU Usage | Memory Usage |
|
||||
| :------------ |:---------------:| -----:|
|
||||
| Crystal (Kemal) | 1.85 | 11.2 MB |
|
||||
| Node.js (ws) | 38.95 | 906.3 MB |
|
||||
|
||||
This benchmark was performed on a 2013 Late Macbook Pro with 2Ghz i7 and 8G ram.
|
||||
|
||||
P.S: Less is better
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue