summary refs log tree commit diff stats
path: root/tests/realtimeGC/nmain.nim
diff options
context:
space:
mode:
authorSimon Hafner <hafnersimon@gmail.com>2015-04-13 22:36:35 -0500
committerSimon Hafner <hafnersimon@gmail.com>2015-04-13 22:36:35 -0500
commitc55f884b5c0ebc0b637138a8de446ba1fd05acdf (patch)
tree0fe74403843327ac380d3fb8a2775b5b74b93371 /tests/realtimeGC/nmain.nim
parentc1d0b2403b3f1c9ca487c362658aefb954ee7d96 (diff)
downloadNim-c55f884b5c0ebc0b637138a8de446ba1fd05acdf.tar.gz
integrated realtimegc stuff into testament
Diffstat (limited to 'tests/realtimeGC/nmain.nim')
-rw-r--r--tests/realtimeGC/nmain.nim46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/realtimeGC/nmain.nim b/tests/realtimeGC/nmain.nim
new file mode 100644
index 000000000..c9f558dbc
--- /dev/null
+++ b/tests/realtimeGC/nmain.nim
@@ -0,0 +1,46 @@
+discard """
+  cmd: "nim $target --debuginfo $options $file"
+  output: "Done"
+"""
+
+import times, os, threadpool
+
+const RUNTIME = 15 * 60 # 15 minutes
+
+when defined(windows):
+  const dllname = "./tests/realtimeGC/shared.dll"
+elif defined(macosx):
+  const dllname = "./tests/realtimeGC/libshared.dylib"
+else:
+  const dllname = "./tests/realtimeGC/libshared.so"
+
+proc status() {.importc: "status", dynlib: dllname.}
+proc count() {.importc: "count", dynlib: dllname.}
+proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.}
+
+proc process() =
+  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)
+    checkOccupiedMem()
+    accumTime = cast[Time]((getTime() - startTime))
+    # echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60))
+
+proc main() =
+  process()
+  # parallel:
+  #   for i in 0..0:
+  #     spawn process()
+  # sync()
+  echo("Done")
+
+main()