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