Skip to content

Instantly share code, notes, and snippets.

@Vindaar
Last active June 16, 2021 18:36
Show Gist options
  • Select an option

  • Save Vindaar/9ced65ce2f7b578a04f5410cdfa2ae4b to your computer and use it in GitHub Desktop.

Select an option

Save Vindaar/9ced65ce2f7b578a04f5410cdfa2ae4b to your computer and use it in GitHub Desktop.

These benches ran on:

basti at DESKTOP-G5IDKB7 in ~/src λ neofetch
       _,met$$$$$gg.          basti@DESKTOP-G5IDKB7
    ,g$$$$$$$$$$$$$$$P.       ---------------------
  ,g$$P"     """Y$$.".        OS: Debian GNU/Linux 10 (buster) on Windows 10 x86_64
 ,$$P'              `$$$.     Kernel: 4.4.0-18362-Microsoft
',$$P       ,ggs.     `$$b:   Uptime: 1 hour, 11 mins
`d$$'     ,$P"'   .    $$$    Packages: 545 (dpkg)
 $$P      d$'     ,    $$P    Shell: zsh 5.7.1
 $$:      $$.   -    ,d$$'    CPU: AMD Ryzen 9 3950X 16- (32) @ 3.493GHz
 $$;      Y$b._   _,d$P'      Memory: 8310MiB / 65485MiB
 Y$$.    `.`"Y$$$$P"'
 `$$b      "-.__
  `Y$$
   `Y$$.
     `$$b.
       `Y$$b.
          `"Y$b._
              `"""

stdlib

The code:

import asynchttpserver, asyncdispatch

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

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

flags:

-d:danger

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/std λ  wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.84ms  488.96us  40.06ms   98.50%
    Req/Sec     4.39k   208.19     7.42k    96.40%
  789166 requests in 15.10s, 37.63MB read
Requests/sec:  52265.46
Transfer/sec:      2.49MB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/std λ  wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.84ms  488.96us  40.06ms   98.50%
    Req/Sec     4.39k   208.19     7.42k    96.40%
  789166 requests in 15.10s, 37.63MB read
Requests/sec:  52265.46
Transfer/sec:      2.49MB

32 threads:

Transfer/sec:      2.51MB
basti at DESKTOP-G5IDKB7 in ~/benchmark/std λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.83ms  422.92us  36.37ms   98.17%
    Req/Sec     3.29k   221.68     7.40k    97.80%
  787367 requests in 15.10s, 37.54MB read
Requests/sec:  52146.15
Transfer/sec:      2.49MB

httpbeast

The code:

import options, asyncdispatch

import httpbeast

proc onRequest(req: Request): Future[void] =
  if req.httpMethod == some(HttpGet):
    case req.path.get()
    of "/":
      req.send("Hello World")
    else:
      req.send(Http404)

run(onRequest)

-d:danger

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     9.55ms   81.12ms   1.82s    98.34%
    Req/Sec     7.28k     2.70k    9.58k    89.07%
  1093095 requests in 15.10s, 110.50MB read
  Socket errors: connect 0, read 0, write 0, timeout 3
Requests/sec:  72391.15
Transfer/sec:      7.32MB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     9.25ms   81.10ms   1.96s    98.46%
    Req/Sec     5.34k     1.98k    6.80k    84.66%
  1043010 requests in 15.10s, 105.44MB read
  Socket errors: connect 0, read 0, write 0, timeout 3
Requests/sec:  69074.60
Transfer/sec:      6.98MB

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.43ms   40.97ms   1.23s    98.80%
    Req/Sec     2.93k   778.24     3.66k    88.87%
  1038395 requests in 15.10s, 104.97MB read
  Socket errors: connect 0, read 0, write 0, timeout 4
Requests/sec:  68767.11
Transfer/sec:      6.95MB

-d:danger –threads:on

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.59ms   49.86ms   1.40s    98.65%
    Req/Sec     7.04k     2.48k    9.72k    69.70%
  1060673 requests in 15.10s, 107.22MB read
  Socket errors: connect 0, read 0, write 0, timeout 6
Requests/sec:  70244.21
Transfer/sec:      7.10MB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.57ms   67.68ms   1.61s    98.59%
    Req/Sec     5.37k     1.97k    7.21k    84.66%
  1049288 requests in 15.10s, 106.07MB read
  Socket errors: connect 0, read 0, write 0, timeout 5
Requests/sec:  69490.16
Transfer/sec:      7.02MB 

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.43ms   60.63ms   1.98s    98.65%
    Req/Sec     2.99k   710.53     3.78k    89.81%
  1047093 requests in 15.10s, 105.85MB read
  Socket errors: connect 0, read 0, write 0, timeout 8
Requests/sec:  69351.02
Transfer/sec:      7.01MB

guildenstern

Code sample 1

The code:

import guildenstern

type
  MyGuildenServer = ref object of GuildenServer
    customserverproperty: string

  MyGuildenVars = ref object of GuildenVars
    customcontextproperty: string

proc onRequest(gv: MyGuildenVars) =
  gv.customcontextproperty = "world"
  gv.reply(((MyGuildenServer)gv.gs).customserverproperty & gv.customcontextproperty)

let server = new MyGuildenServer
server.customserverproperty = "hello,"
server.registerHttphandler(onRequest, [])
serve[MyGuildenVars](server, 8080)

-d:danger

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.49ms   80.73ms   1.89s    98.78%
    Req/Sec    24.54k    19.19k   50.98k    33.85%
  1103387 requests in 15.10s, 52.61MB read
  Socket errors: connect 0, read 0, write 0, timeout 9
Requests/sec:  73077.64
Transfer/sec:      3.48MB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     4.92ms   57.28ms   1.90s    98.89%
    Req/Sec    24.37k    21.93k   55.56k    32.83%
  1114975 requests in 15.10s, 53.17MB read
  Socket errors: connect 0, read 0, write 0, timeout 4
Requests/sec:  73852.24
Transfer/sec:      3.52MB

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     7.26ms   78.54ms   1.99s    98.68%
    Req/Sec    23.66k    21.14k   54.08k    31.99%
  1110685 requests in 15.09s, 52.96MB read
  Socket errors: connect 0, read 0, write 0, timeout 22
Requests/sec:  73579.90
Transfer/sec:      3.51MB

-d:danger -d:threadsafe –threads:on

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   153.25ms   1.05s    94.38%
    Req/Sec    17.43     13.73    70.00     65.22%
  1387 requests in 15.07s, 67.72KB read
Requests/sec:     92.02
Transfer/sec:      4.49KB

Uhm, wtf.

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   153.95ms   1.05s    94.37%
    Req/Sec    15.36     12.93    50.00     45.97%
  1386 requests in 15.07s, 67.68KB read
Requests/sec:     91.94
Transfer/sec:      4.49KB

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   154.10ms   1.05s    94.29%
    Req/Sec     5.01      6.40    30.00     87.75%
  1384 requests in 15.07s, 67.58KB read
Requests/sec:     91.86
Transfer/sec:      4.49KB

Code sample 2

import guildenstern

proc onRequest(gv: GuildenVars) =
  gv.reply("Hello World")

let server = new GuildenServer
server.registerHttphandler(onRequest, [])
serve[GuildenVars](server, 8080)

-d:danger

12 threads

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     6.17ms   64.95ms   1.93s    98.61%
    Req/Sec    25.80k    20.59k   52.78k    34.55%
  1121507 requests in 15.10s, 53.48MB read
  Socket errors: connect 0, read 0, write 0, timeout 4
Requests/sec:  74279.33
Transfer/sec:      3.54MB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     5.32ms   58.67ms   1.63s    98.79%
    Req/Sec    25.01k    24.02k   59.44k    36.20%
  1126988 requests in 15.10s, 53.74MB read
  Socket errors: connect 0, read 0, write 0, timeout 12
Requests/sec:  74648.69
Transfer/sec:      3.56MB

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     2.96ms   34.99ms   1.24s    98.84%
    Req/Sec    24.21k    18.58k   48.12k    32.75%
  1109902 requests in 15.10s, 52.92MB read
  Socket errors: connect 0, read 0, write 0, timeout 4
Requests/sec:  73524.62
Transfer/sec:      3.51MB

-d:danger -d:threadsafe –threads:on

12 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t12 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  12 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   153.11ms   1.05s    94.38%
    Req/Sec    16.12     11.29    50.00     53.21%
  1388 requests in 15.07s, 67.77KB read
Requests/sec:     92.09
Transfer/sec:      4.50KB

16 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t16 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  16 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   153.42ms   1.05s    94.38%
    Req/Sec    15.30     12.47    49.00     48.52%
  1387 requests in 15.07s, 67.72KB read
Requests/sec:     92.07
Transfer/sec:      4.50KB

32 threads:

basti at DESKTOP-G5IDKB7 in ~/benchmark/httpbeast λ wrk -t32 -c100 -d15s http://localhost:8080
Running 15s test @ http://localhost:8080
  32 threads and 100 connections
  Thread Stats   Avg      Stdev     Max   +/- Stdev
    Latency     1.01s   153.68ms   1.05s    94.29%
    Req/Sec     4.97      6.44    30.00     87.44%
  1384 requests in 15.05s, 67.58KB read
Requests/sec:     91.95
Transfer/sec:      4.49KB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment