diff options
Diffstat (limited to 'tests/gc/gcbench.nim')
-rw-r--r-- | tests/gc/gcbench.nim | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/tests/gc/gcbench.nim b/tests/gc/gcbench.nim index fc5d6864f..e29ea762d 100644 --- a/tests/gc/gcbench.nim +++ b/tests/gc/gcbench.nim @@ -44,7 +44,7 @@ discard """ # - No way to check on memory use # - No cyclic data structures # - No attempt to measure variation with object size -# - Results are sensitive to locking cost, but we dont +# - Results are sensitive to locking cost, but we don't # check for proper locking # @@ -53,11 +53,11 @@ import type PNode = ref TNode - TNode {.final.} = object + TNode {.final, acyclic.} = object left, right: PNode i, j: int -proc newNode(L, r: PNode): PNode = +proc newNode(L, r: sink PNode): PNode = new(result) result.left = L result.right = r @@ -97,8 +97,8 @@ proc makeTree(iDepth: int): PNode = return newNode(makeTree(iDepth-1), makeTree(iDepth-1)) proc printDiagnostics() = - echo("Total memory available: " & $getTotalMem() & " bytes") - echo("Free memory: " & $getFreeMem() & " bytes") + echo("Total memory available: " & formatSize(getTotalMem()) & " bytes") + echo("Free memory: " & formatSize(getFreeMem()) & " bytes") proc timeConstruction(depth: int) = var @@ -166,9 +166,15 @@ proc main() = var elapsed = epochTime() - t printDiagnostics() - echo("Completed in " & $elapsed & "ms. Success!") + echo("Completed in " & $elapsed & "s. Success!") + when declared(getMaxMem): + echo "Max memory ", formatSize getMaxMem() when defined(GC_setMaxPause): GC_setMaxPause 2_000 +when defined(gcDestructors): + let mem = getOccupiedMem() main() +when defined(gcDestructors): + doAssert getOccupiedMem() == mem |