====== Lines of Code ====== You need to add this method to CmMethodLOC: measureLoc: method "Answer the number of lines of code in @method. PARAMETERS method RETURN VALUE " | source sourceNode | source := self cachedSourceFor: method. (sourceNode := self cachedParseTreeFor: method) isNil ifTrue: [^0]. sourceNode statements isEmpty ifTrue: [^0]. ^self linesOfCodeIn: source using: sourceNode ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ | apps classes loc methods names instVars bm cml mm mi ml maxInst | names := #('Jw' ). "<---------------------------- put your application prefixes here" apps := System loadedApplications. instVars := loc := maxInst := 0. maxMeth := 0. cml := CmMethodLOC new. bm := Set new. apps := apps select: [:each ||cnt| cnt := 0. names do: [:each2 | cnt := cnt + (each name asString indexOfSubCollection: each2 startingAt: 1 ifAbsent: [0])]. cnt > 0]. Transcript show: 'Apps ', apps size printString;cr. apps do: [:each | Transcript show: each printString;cr]. classes := OrderedCollection new. methods := OrderedCollection new. apps do: [:each | classes addAll: each allLocalClasses]. Transcript show: 'Classes ', classes size printString;cr. maxCnt := 0. classes do: [:each ||localMeth| instVars := instVars + each instSize. each instSize > maxInst ifTrue: [maxInst := each instSize. instCl := each name]. localMeth := (each methodsArray select: [:e | e notNil]). localMeth := localMeth select: [:e | (e class = CompiledMethod)]. localMeth size > maxMeth ifTrue: [maxMeth := localMeth size. methCl := each class name]. locCnt := 0. localMeth do: [:e | locCnt := locCnt + (cml measureLoc: e)]. locCnt > maxCnt ifTrue: [maxCnt := locCnt. maxCl := each class name]. loc := loc + locCnt. methods addAll: localMeth. ]. Transcript show: 'Total number of methods ', methods size printString;cr. "methods do: [:each | loc := loc + (cml measureLoc: each)]." Transcript show: 'Total Lines of code ', loc printString;cr. Transcript show: 'Average Lines of code per method ', (loc / methods size asFloat) printString;cr.