Guest User

Untitled

a guest
Jun 26th, 2018
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. | class test trace classTrace result  |
  2.  
  3. class := Time.
  4. test := TimeTest.
  5.  
  6. trace := Dictionary new.
  7.  
  8. thisContext runSimulated: [test suite run]  contextAtEachStep: [ :current |
  9.       | cls sel methods bytecodes |
  10.        cls := current method methodClass.
  11.        sel := current method selector.
  12.        methods := trace at: cls ifAbsentPut: Dictionary new.
  13.        bytecodes := methods at: sel ifAbsentPut: Set new.
  14.        bytecodes add: current pc.]
  15.  
  16. trace .
  17.  
  18. result := String streamContents: [:s |
  19.  
  20. classTrace := trace at: class ifAbsent: nil.
  21. classTrace
  22.        ifNil: [
  23.                s nextPutAll: 'Class ', class name, ' not called'; cr. ]
  24.        ifNotNil: [
  25.                s nextPutAll: class name; cr.
  26.                class selectorsDo: [:sel |
  27.                       | m usedBytecodes allBytecodes |
  28.                        m := class >> sel.
  29.                        usedBytecodes := (classTrace at: sel ifAbsent: Set new) size.
  30.                        allBytecodes := 0.
  31.                        m symbolicLinesDo: [:pc :lineForPC | allBytecodes := allBytecodes + 1 ]..
  32.                        s tab; nextPutAll: sel; nextPutAll: ' - '; nextPutAll:
  33. (usedBytecodes  /  allBytecodes * 100) asFloat asString; nextPutAll:
  34. '%'; cr. ]].
  35. ].
  36. result..
Add Comment
Please, Sign In to add comment