Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- | class test trace classTrace result |
- class := Time.
- test := TimeTest.
- trace := Dictionary new.
- thisContext runSimulated: [test suite run] contextAtEachStep: [ :current |
- | cls sel methods bytecodes |
- cls := current method methodClass.
- sel := current method selector.
- methods := trace at: cls ifAbsentPut: Dictionary new.
- bytecodes := methods at: sel ifAbsentPut: Set new.
- bytecodes add: current pc.]
- trace .
- result := String streamContents: [:s |
- classTrace := trace at: class ifAbsent: nil.
- classTrace
- ifNil: [
- s nextPutAll: 'Class ', class name, ' not called'; cr. ]
- ifNotNil: [
- s nextPutAll: class name; cr.
- class selectorsDo: [:sel |
- | m usedBytecodes allBytecodes |
- m := class >> sel.
- usedBytecodes := (classTrace at: sel ifAbsent: Set new) size.
- allBytecodes := 0.
- m symbolicLinesDo: [:pc :lineForPC | allBytecodes := allBytecodes + 1 ]..
- s tab; nextPutAll: sel; nextPutAll: ' - '; nextPutAll:
- (usedBytecodes / allBytecodes * 100) asFloat asString; nextPutAll:
- '%'; cr. ]].
- ].
- result..
Add Comment
Please, Sign In to add comment