Last active
August 29, 2015 14:12
-
-
Save def-/d212777a33be5de0c976 to your computer and use it in GitHub Desktop.
Jester Performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asynchttpserver, asyncdispatch | |
var server = newAsyncHttpServer() | |
proc cb(req: Request) {.async.} = | |
await req.respond(Http200, "{ \"message\": \"Hello, World!\"}") | |
asyncCheck server.serve(Port(8000), cb) | |
runForever() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import asyncnet, asyncdispatch | |
proc processClient(client: AsyncSocket) {.async.} = | |
let line = await client.recvLine() | |
await client.send("""HTTP/1.1 200 OK | |
Date: Mon, 23 May 2005 22:38:34 GMT | |
Server: Apache/1.3.3.7 (Unix) (Red-Hat/Linux) | |
Last-Modified: Wed, 08 Jan 2003 23:11:55 GMT | |
ETag: "3f80f-1b6-3e1cb03b" | |
Content-Type: text/html; charset=UTF-8 | |
Content-Length: 131 | |
Accept-Ranges: bytes | |
Connection: close | |
<html> | |
<head> | |
<title>An Example Page</title> | |
</head> | |
<body> | |
Hello World, this is a very simple HTML document. | |
</body> | |
</html> | |
""") | |
client.close() | |
proc serve() {.async.} = | |
var server = newAsyncSocket() | |
server.bindAddr(Port(8004)) | |
server.listen() | |
while true: | |
let client = await server.accept() | |
asyncCheck processClient(client) | |
asyncCheck serve() | |
runForever() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Using https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Nimrod/jester/hello.nim (made it work with current Jester) | |
./wrk -t12 -c400 -d30s http://127.0.0.1:8000/json | |
Requests/sec Transfer/sec | |
debug 743.80 72.95KB | |
release 6108.49 596.81KB | |
>/dev/null 6623.22 647.12KB | |
asynchttpserver 14021.24 0.91MB | |
cppsp 110135.78 69.85MB |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment