tmain.nim 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. discard """
  2. cmd: "nim $target --threads:on -d:release -d:useRealtimeGC $options $file"
  3. joinable:false
  4. """
  5. #[
  6. was: cmd: "nim $target --debuginfo $options $file"
  7. these dont' seem needed --debuginfo
  8. nor these from the previous main.nim.cfg: --app:console
  9. ]#
  10. #[
  11. Test the realtime GC without linking nimrtl.dll/so.
  12. To build by hand and run the test for 35 minutes:
  13. `nim r --threads:on -d:runtimeSecs:2100 tests/realtimeGC/tmain.nim`
  14. ]#
  15. import times, os, strformat, strutils
  16. from stdtest/specialpaths import buildDir
  17. # import threadpool
  18. const runtimeSecs {.intdefine.} = 5
  19. const file = "shared.nim"
  20. const dllname = buildDir / (DynlibFormat % "shared_D20210524T180506")
  21. static:
  22. # D20210524T180826:here we compile the dependency on the fly
  23. let nim = getCurrentCompilerExe()
  24. let (output, exitCode) = gorgeEx(fmt"{nim} c -o:{dllname} --debuginfo --app:lib --threads:on -d:release -d:useRealtimeGC {file}")
  25. doAssert exitCode == 0, output
  26. proc status() {.importc: "status", dynlib: dllname.}
  27. proc count() {.importc: "count", dynlib: dllname.}
  28. proc checkOccupiedMem() {.importc: "checkOccupiedMem", dynlib: dllname.}
  29. proc process() =
  30. let startTime = getTime()
  31. let runTime = cast[Time](runtimeSecs)
  32. var accumTime: Time
  33. while accumTime < runTime:
  34. for i in 0..10:
  35. count()
  36. # echo("1. sleeping... ")
  37. sleep(500)
  38. for i in 0..10:
  39. status()
  40. # echo("2. sleeping... ")
  41. sleep(500)
  42. checkOccupiedMem()
  43. accumTime = cast[Time]((getTime() - startTime))
  44. # echo("--- Minutes left to run: ", int(int(runTime-accumTime)/60))
  45. proc main() =
  46. process()
  47. # parallel:
  48. # for i in 0..0:
  49. # spawn process()
  50. # sync()
  51. main()