If you subscribe to pharo-dev you will have seen that I’ve been looking
at the primitives used in DiskStore.
As part of that investigation I wanted to get an idea of which messages
are typically sent to DiskStore and how often.
Denis Kudriashov provided a neat package that implements a “halt on
next object call”. I’ve been wanting to play with the package for a
while and decided this was a good opportunity.
I’ve extended that package to keep count of how many times messages are
sent to a target object, e.g.:
| point trace |
point := 2@3.
trace := ExternalSendStats logStatsFor: point.
The package is probably too simplistic, and there’s bound to be other
ways to do this, but it met my immediate needs and gave me a chance to
try out the Ghost package. I’ll extend it if and when I need to.
Many thanks to Denis for making the Ghost package available, and
hopefully this is useful for someone, or at least triggers some new
Denis’ original article is at: http://dionisiydk.blogspot.cz/2016/04/halt-next-object-call.html
The extensions can be installed with:
aMessage sendTo: anObject
which produces another intercepting message #perform:withArguments which repeats original message send.
ExternalSendTrace>>send: aMessage to: anObject| method |announcer announce: (ExternalSendAnnouncement message: aMessage trace: self).method := anObject class lookupSelector: aMessage selector.^GHMetaMessages executeWith: anObject andArguments: aMessage arguments method: method
rect := 10@30 corner: firstname.lastname@example.org := ExternalSendStats logStatsFor: rect.rect area.trace stats.“a Dictionary(#area->1 #height->1 #width->1 )”