summary refs log tree commit diff stats
path: root/tests/realtimeGC/main.nim
diff options
context:
space:
mode:
Diffstat (limited to 'tests/realtimeGC/main.nim')
-rw-r--r--tests/realtimeGC/main.nim40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/realtimeGC/main.nim b/tests/realtimeGC/main.nim
new file mode 100644
index 000000000..5496cd999
--- /dev/null
+++ b/tests/realtimeGC/main.nim
@@ -0,0 +1,40 @@
+discard """
+  cmd: "nim $target --debuginfo $options $file"
+  output: "Done"
+"""
+
+import times
+import os
+
+const RUNTIME = 35 * 60 # 35 minutes
+
+when defined(windows):
+  const dllname = "./shared.dll"
+elif defined(macosx):
+  const dllname = "./libshared.dylib"
+else:
+  const dllname = "./libshared.so"
+
+proc status() {.importc: "status", dynlib: dllname.}
+proc count() {.importc: "count", dynlib: dllname.}
+proc occupiedMem() {.importc: "occupiedMem", dynlib: dllname.}
+
+proc main() =
+  let startTime = getTime()
+  let runTime = cast[Time](RUNTIME) #
+  var accumTime: Time
+  while accumTime < runTime:
+    for i in 0..10:
+      count()
+    #echo("1. sleeping... ")
+    sleep(500)
+    for i in 0..10:
+      status()
+    #echo("2. sleeping... ")
+    sleep(500)
+    occupiedMem()
+    accumTime = cast[Time]((getTime() - startTime))
+    #echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60))
+  echo("Done")
+
+main()