Eliot Miranda uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-eem.1045.mcz ==================== Summary ==================== Name: System-eem.1045 Author: eem Time: 31 October 2018, 3:38:52.935624 pm UUID: aece8105-e853-4c18-a38e-6872b4cd1440 Ancestors: System-fn.1044 Sort by name within bins when printing the results of a SpaceTally. =============== Diff against System-fn.1044 =============== Item was changed: ----- Method: SpaceTally>>printSpaceAnalysis:onStream: (in category 'fileOut') ----- printSpaceAnalysis: threshold onStream: stream "If threshold > 0, then only those classes with more than that number of instances will be shown, and they will be sorted by total instance space. If threshold = 0, then all classes will appear, sorted by name." | totalCodeSpace totalInstCount totalInstSpace totalPercent classNameLength printRow | self systemWideSpaceTally. totalCodeSpace := totalInstCount := totalInstSpace := 0. classNameLength := 1. results do: [ :each | classNameLength := classNameLength max: each analyzedClassName size. totalCodeSpace := totalCodeSpace + each codeSize. totalInstCount := totalInstCount + each instanceCount. totalInstSpace := totalInstSpace + each spaceForInstances ]. totalPercent := 0.0. printRow := [ :class :codeSpace :instanceCount :instanceSpace :percent | stream nextPutAll: (class padded: #right to: classNameLength + 1 with: $ ); nextPutAll: (codeSpace padded: #left to: 12 with: $ ); nextPutAll: (instanceCount padded: #left to: 12 with: $ ); nextPutAll: (instanceSpace padded: #left to: 14 with: $ ); nextPutAll: (percent padded: #left to: 8 with: $ ); cr ]. stream timeStamp. printRow valueWithArguments: { 'Class'. 'code space'. '# instances'. 'inst space'. 'percent' }. + threshold > 0 + ifTrue: "If inst count threshold > 0, then sort by space" + [results := results select: [ :s | + s instanceCount >= threshold + or: [s spaceForInstances > (totalInstSpace // 500) ] ]. + results sort: [ :s :s2 | + s spaceForInstances > s2 spaceForInstances + or: [s spaceForInstances = s2 spaceForInstances + and: [s analyzedClassName < s2 analyzedClassName] ] ] ] + ifFalse: "Otherwise sort by name" + [results sort: [ :s :s2 | s analyzedClassName < s2 analyzedClassName]]. - threshold > 0 ifTrue: [ - "If inst count threshold > 0, then sort by space" - results := results select: [ :s | - s instanceCount >= threshold or: [ - s spaceForInstances > (totalInstSpace // 500) ] ]. - results sort: [ :s :s2 | s spaceForInstances > s2 spaceForInstances ] ]. results do: [ :s | | percent | percent := s spaceForInstances * 100.0 / totalInstSpace. totalPercent := totalPercent + percent. printRow valueWithArguments: { s analyzedClassName. s codeSize printString. s instanceCount printString. s spaceForInstances asBytesDescription. percent printShowingDecimalPlaces: 1 } ]. stream cr. printRow valueWithArguments: { 'Total'. totalCodeSpace printString. totalInstCount printString. totalInstSpace printString. totalPercent printShowingDecimalPlaces: 1 }! |
Free forum by Nabble | Edit this page |