A simple but intriguing analysing snippet

Stephane Ducasse ducasse at iam.unibe.ch
Mon Dec 31 12:05:01 UTC 2001


Hi

It is always fun to see how we can rapidly build some query to understand
better Smalltalk. 
The following script (which takes a while) sorts all the classes by the
number of instances they have in the image....The results are certainly
interesting for some of you.

Have fun


| classes classByInstanceNumber |
classes := OrderedCollection new: Metaclass instanceCount.
Object withAllSubclasses do: [:each |  (each isKindOf: Metaclass)
                                            ifFalse: [classes add: each ]].
classByInstanceNumber := SortedCollection sortBlock: [:a :b | a value> b
value].
    'Analysing...'
        displayProgressAt: Sensor cursorPoint
        from: 0 to: classes size
        during: [:bar |
                      classes
                            doWithIndex: [:each :i |
                                    classByInstanceNumber add: (each name ->
each instanceCount). bar value: i]].
    classByInstanceNumber inspect.
    classByInstanceNumber


I'm wondering why we do not have better analysis tools in Smalltalk. With
all this power available.

Stef





More information about the Squeak-dev mailing list