In the ORC example benchmark from the [Post about
ORC](https://nim-lang.org/blog/2020/12/08/introducing-orc.html) the request
doesn't use sessions.
I wonder how this example would look like, when request would need a) create
sessions on demand b) Read/write to sessions made of complex GC data structures
with refs and objects?
The code:
import asynchttpserver, asyncdispatch, strutils, json, tables, streams
# about 135 MB of live data:
var sessions: Table[string, JsonNode]
for i in 0 ..< 10:
sessions[$i] = parseJson(newFileStream("1.json", fmRead), "1.json")
var served = 0
var server = newAsyncHttpServer()
proc cb(req: Request) {.async.} =
inc served
await req.respond(Http200, "Hello World")
if served mod 10 == 0:
when not defined(memForSpeed):
GC_fullCollect()
waitFor server.serve(Port(8080), cb)
Run