print out memo hits/misses

This commit is contained in:
Edward Amsden 2022-02-14 23:08:08 -06:00
parent a5302f3b8b
commit 4bbb786861
No known key found for this signature in database
GPG Key ID: 548EDF608CA956F6
2 changed files with 6 additions and 1 deletions

View File

@ -1,3 +1,3 @@
/+ subject-knowledge
|= [s=sock:subject-knowledge f=*]
(pull:subject-knowledge bord:subject-knowledge s f)
-:(pull:subject-knowledge bord:subject-knowledge s f)

View File

@ -386,21 +386,26 @@
|= [s=sock f=sock]
^- [coot _memo]
?. ?= [%know *] f
~& "Dyn: {<s>}"
[[%dyn s] memo]
=/ jet (juke jute s k.f)
?. ?= ~ jet
:: found a jet
~& "Jet: {<+.u.jet>}"
[[%jet +.u.jet] memo]
=/ mem (~(get by memo) [s k.f])
?~ mem
:: memo miss
=. memo (~(put by memo) [s k.f] `(unit sock)`~) :: blackhole for recursive eval
=^ res memo ^$(s s, f k.f)
~& "Miss: {<[s k.f]>}"
[[%mis res] (~(put by memo) [s k.f] `(unit sock)``r.res)] :: fill in result
?~ u.mem
:: memo blackhole
~& "Recur: {<[s k.f]>}"
[[%rec s k.f] memo]
:: memo hit
~& "Hit: {<[s k.f]>}"
[[%hit u.u.mem] memo]
?+ f ~| %pull-bonk !!
::