thamming_orc test created/destroyed counts match (#18471)
The thamming_orc.nim code now counts all created objects being tested, not just the ones following the "first 20" test, and the position of the `destroyed += 1` counter has been adjusted so it counts all the calls that are as a result of `=trace` tracing and not just the original destruction calls.
This commit is contained in:
parent
980a9ed523
commit
9ffc70851b
1 changed files with 4 additions and 4 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
discard """
|
discard """
|
||||||
output: '''(allocCount: 1114, deallocCount: 1112)
|
output: '''(allocCount: 1114, deallocCount: 1112)
|
||||||
created 439 destroyed 402'''
|
created 491 destroyed 491'''
|
||||||
cmd: "nim c --gc:orc -d:nimAllocStats $file"
|
cmd: "nim c --gc:orc -d:nimAllocStats $file"
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
@ -94,8 +94,8 @@ type
|
||||||
var destroyed = 0
|
var destroyed = 0
|
||||||
|
|
||||||
proc `=destroy`(ll: var LazyListObj) =
|
proc `=destroy`(ll: var LazyListObj) =
|
||||||
if ll.tlf == nil and ll.tl == nil: return
|
|
||||||
destroyed += 1
|
destroyed += 1
|
||||||
|
if ll.tlf == nil and ll.tl == nil: return
|
||||||
|
|
||||||
when defined(trace20):
|
when defined(trace20):
|
||||||
echo "destroying: ", (destroyed, ll.hd[1].convertTriVal2BigInt)
|
echo "destroying: ", (destroyed, ll.hd[1].convertTriVal2BigInt)
|
||||||
|
|
@ -140,7 +140,7 @@ proc main =
|
||||||
"Algorithmic error finding first 20 Hamming numbers!!!"
|
"Algorithmic error finding first 20 Hamming numbers!!!"
|
||||||
|
|
||||||
when not defined(trace20):
|
when not defined(trace20):
|
||||||
var lsth: TriVal; created = 0; destroyed = 0
|
var lsth: TriVal
|
||||||
for h in hammings(200): lsth = h
|
for h in hammings(200): lsth = h
|
||||||
doAssert $lsth.convertTriVal2BigInt == "16200",
|
doAssert $lsth.convertTriVal2BigInt == "16200",
|
||||||
"Algorithmic error finding 200th Hamming number!!!"
|
"Algorithmic error finding 200th Hamming number!!!"
|
||||||
|
|
@ -149,7 +149,7 @@ let mem = getOccupiedMem()
|
||||||
main()
|
main()
|
||||||
GC_FullCollect()
|
GC_FullCollect()
|
||||||
let mb = getOccupiedMem() - mem
|
let mb = getOccupiedMem() - mem
|
||||||
#doAssert mb == 0, "Found memory leak of " & $mb & " bytes!!!"
|
doAssert mb == 0, "Found memory leak of " & $mb & " bytes!!!"
|
||||||
|
|
||||||
echo getAllocStats()
|
echo getAllocStats()
|
||||||
echo "created ", created, " destroyed ", destroyed
|
echo "created ", created, " destroyed ", destroyed
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue