From c59dd29190a9cfe4c542cb43fb5d2931fe094c4f Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Fri, 26 Aug 2022 12:26:03 -0500 Subject: [PATCH] Add stress test for marshalling to examples. --- examples/marshal-stress.janet | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 examples/marshal-stress.janet diff --git a/examples/marshal-stress.janet b/examples/marshal-stress.janet new file mode 100644 index 00000000..b966b9ff --- /dev/null +++ b/examples/marshal-stress.janet @@ -0,0 +1,30 @@ +(defn init-db [c] + (def res @{:clients @{}}) + (var i 0) + (repeat c + (def n (string "client" i)) + (put-in res [:clients n] @{:name n :projects @{}}) + (++ i) + (repeat c + (def pn (string "project" i)) + (put-in res [:clients n :projects pn] @{:name pn}) + (++ i) + (repeat c + (def tn (string "task" i)) + (put-in res [:clients n :projects pn :tasks tn] @{:name pn}) + (++ i)))) + res) + +(loop [c :range [30 80 1]] + (var s (os/clock)) + (print "Marshal DB with " c " clients, " + (* c c) " projects and " + (* c c c) " tasks. " + "Total " (+ (* c c c) (* c c) c) " tables") + (def buf (marshal (init-db c) @{} @"")) + (print "Buffer is " (length buf) " bytes") + (print "Duration " (- (os/clock) s)) + (set s (os/clock)) + (gccollect) + (print "Collected garbage in " (- (os/clock) s))) +