Skip to content

Instantly share code, notes, and snippets.

@dom96
Last active January 12, 2017 21:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dom96/b3b6f45a5aba63077c090dd0ff9016e9 to your computer and use it in GitHub Desktop.
Save dom96/b3b6f45a5aba63077c090dd0ff9016e9 to your computer and use it in GitHub Desktop.

Rust

~ » wrk -c 10 -t 4 -d 10s http://localhost:8080/plaintext
Running 10s test @ http://localhost:8080/plaintext
  4 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   122.52us   60.65us   3.49ms   92.02%
    Req/Sec    16.12k     1.48k   17.62k    88.86%
  647915 requests in 10.10s, 79.71MB read
Requests/sec:  64151.56
Transfer/sec:      7.89MB

Code used: tokio-minihttp examples/techempower.rs

Note: It appears that tokio-minihttp is actually running on two threads meaning that it must be utilizing my two CPU cores. Nim on the other hand is single threaded.

Nim

Compiled with -d:release -d:useRealtimeGC and GC_setMaxPause(10).

~ » wrk -c 10 -t 4 -d 10s http://localhost:8080/plaintext
Running 10s test @ http://localhost:8080/plaintext
  4 threads and 10 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency   207.64us   64.55us   2.68ms   94.94%
    Req/Sec     9.60k   566.43    10.26k    84.90%
  385992 requests in 10.10s, 18.41MB read
Requests/sec:  38216.87
Transfer/sec:      1.82MB

Code used:

import asynchttpserver, asyncdispatch

var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
  await req.respond(Http200, "Hello World")

GC_setMaxPause(10)
waitFor server.serve(Port(8080), cb)

Note: This is single threaded!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment