diff --git a/src/IllimaniProfiler/IllEphemeron.class.st b/src/IllimaniProfiler/IllEphemeron.class.st index ef21ad0..6c84f81 100644 --- a/src/IllimaniProfiler/IllEphemeron.class.st +++ b/src/IllimaniProfiler/IllEphemeron.class.st @@ -58,8 +58,8 @@ IllEphemeron >> initialize [ super initialize. initializationTime := Time primUTCMicrosecondsClock. - scavengesAtStart := Smalltalk vm incrementalGCCount. - fullGCsAtStart := Smalltalk vm fullGCCount + survivedScavenges := Smalltalk vm incrementalGCCount. + survivedFullGC := Smalltalk vm fullGCCount ] { #category : 'inspector' } @@ -98,8 +98,8 @@ IllEphemeron >> mourn [ key := nil. finalizationTime := Time primUTCMicrosecondsClock. - survivedScavenges := Smalltalk vm incrementalGCCount - scavengesAtStart. - survivedFullGC := Smalltalk vm fullGCCount - fullGCsAtStart + survivedScavenges := Smalltalk vm incrementalGCCount - survivedScavenges. + survivedFullGC := Smalltalk vm fullGCCount - survivedFullGC ] { #category : 'printing' } @@ -121,3 +121,15 @@ IllEphemeron >> sizeInBytes: anObject [ sizeInBytes := anObject ] + +{ #category : 'accessing' } +IllEphemeron >> survivedFullGC [ + + ^ survivedFullGC +] + +{ #category : 'accessing' } +IllEphemeron >> survivedScavenges [ + + ^ survivedScavenges +] diff --git a/src/IllimaniUI/AllocationsGroupedByTablePresenter.class.st b/src/IllimaniUI/AllocationsGroupedByTablePresenter.class.st new file mode 100644 index 0000000..f4fc2fb --- /dev/null +++ b/src/IllimaniUI/AllocationsGroupedByTablePresenter.class.st @@ -0,0 +1,79 @@ +Class { + #name : 'AllocationsGroupedByTablePresenter', + #superclass : 'SpPresenter', + #instVars : [ + 'tablePresenter', + 'totalMemory', + 'totalAllocations', + 'groupedAllocations' + ], + #category : 'IllimaniUI-Widgets', + #package : 'IllimaniUI', + #tag : 'Widgets' +} + +{ #category : 'initialization' } +AllocationsGroupedByTablePresenter >> connectPresenters [ + + tablePresenter whenSelectedDo: [ :item | item value inspect ] +] + +{ #category : 'initialization' } +AllocationsGroupedByTablePresenter >> convertToPercentageString: aNumber [ + + ^ (aNumber * 100 printShowingDecimalPlaces: 2) , '%' +] + +{ #category : 'layout' } +AllocationsGroupedByTablePresenter >> defaultLayout [ + + ^ SpBoxLayout newTopToBottom + add: tablePresenter; + yourself +] + +{ #category : 'accessing - model' } +AllocationsGroupedByTablePresenter >> groupAllocations: someObjectAllocations [ + + ^ self subclassResponsibility +] + +{ #category : 'initialization' } +AllocationsGroupedByTablePresenter >> initializePresenters [ + + tablePresenter := self newTable + activateOnSingleClick; + items: groupedAllocations; + alternateRowsColor; + addColumn: (SpStringTableColumn + title: self titleForGroupingColumn + evaluated: [ :assoc | assoc key ]); + addColumn: (SpStringTableColumn + title: 'Total allocated memory' + evaluated: [ :assoc | (assoc value sum: [ :e | e sizeInBytes ]) humanReadableByteSizeString ]); + addColumn: (SpStringTableColumn + title: '% Memory' + evaluated: [ :assoc | self convertToPercentageString: (assoc value sum: [ :e | e sizeInBytes ]) / totalMemory ]); + addColumn: (SpStringTableColumn + title: '# of allocated objects' + evaluated: [ :assoc | assoc value size asStringWithCommas ]); + addColumn: (SpStringTableColumn + title: '% Allocated objects' + evaluated: [ :assoc | self convertToPercentageString: (assoc value size / totalAllocations) ]); + yourself +] + +{ #category : 'accessing - model' } +AllocationsGroupedByTablePresenter >> setModelBeforeInitialization: someObjectAllocations [ + + groupedAllocations := self groupAllocations: someObjectAllocations. + groupedAllocations sort: [ :a :b | a key < b key ]. + totalMemory := groupedAllocations sum: [ :assoc | assoc value sum: [ :e | e sizeInBytes ] ]. + totalAllocations := groupedAllocations sum: [ :assoc | assoc value size ]. +] + +{ #category : 'initialization' } +AllocationsGroupedByTablePresenter >> titleForGroupingColumn [ + + ^ self subclassResponsibility +] diff --git a/src/IllimaniUI/FinalizationFullGCCyclesTablePresenter.class.st b/src/IllimaniUI/FinalizationFullGCCyclesTablePresenter.class.st new file mode 100644 index 0000000..342557f --- /dev/null +++ b/src/IllimaniUI/FinalizationFullGCCyclesTablePresenter.class.st @@ -0,0 +1,20 @@ +Class { + #name : 'FinalizationFullGCCyclesTablePresenter', + #superclass : 'AllocationsGroupedByTablePresenter', + #category : 'IllimaniUI-Widgets', + #package : 'IllimaniUI', + #tag : 'Widgets' +} + +{ #category : 'accessing - model' } +FinalizationFullGCCyclesTablePresenter >> groupAllocations: someObjectAllocations [ + + ^ (someObjectAllocations groupedBy: [ :allocationModel | + allocationModel survivedFullGC ]) associations +] + +{ #category : 'initialization' } +FinalizationFullGCCyclesTablePresenter >> titleForGroupingColumn [ + + ^ '# of full GCs survived' +] diff --git a/src/IllimaniUI/FinalizationLifetimesTablePresenter.class.st b/src/IllimaniUI/FinalizationLifetimesTablePresenter.class.st index 2f48709..5a92d24 100644 --- a/src/IllimaniUI/FinalizationLifetimesTablePresenter.class.st +++ b/src/IllimaniUI/FinalizationLifetimesTablePresenter.class.st @@ -1,68 +1,20 @@ Class { #name : 'FinalizationLifetimesTablePresenter', - #superclass : 'SpPresenter', - #instVars : [ - 'tablePresenter', - 'groupedAllocationsBySeconds', - 'totalMemory', - 'totalAllocations' - ], + #superclass : 'AllocationsGroupedByTablePresenter', #category : 'IllimaniUI-Widgets', #package : 'IllimaniUI', #tag : 'Widgets' } -{ #category : 'initialization' } -FinalizationLifetimesTablePresenter >> connectPresenters [ - - tablePresenter whenSelectedDo: [ :item | item value inspect ] -] - -{ #category : 'initialization' } -FinalizationLifetimesTablePresenter >> convertToPercentageString: aNumber [ - - ^ (aNumber * 100 printShowingDecimalPlaces: 2) , '%' -] - -{ #category : 'layout' } -FinalizationLifetimesTablePresenter >> defaultLayout [ +{ #category : 'accessing - model' } +FinalizationLifetimesTablePresenter >> groupAllocations: someObjectAllocations [ - ^ SpBoxLayout newTopToBottom - add: tablePresenter; - yourself + ^ (someObjectAllocations groupedBy: [ :allocationModel | + allocationModel lifetimeAsDuration asSeconds ]) associations ] { #category : 'initialization' } -FinalizationLifetimesTablePresenter >> initializePresenters [ - - tablePresenter := self newTable - activateOnSingleClick; - items: groupedAllocationsBySeconds; - alternateRowsColor; - addColumn: (SpStringTableColumn - title: 'Lifetime duration (seconds)' - evaluated: [ :assoc | assoc key ]); - addColumn: (SpStringTableColumn - title: 'Total allocated memory' - evaluated: [ :assoc | (assoc value sum: [ :e | e sizeInBytes ]) humanReadableByteSizeString ]); - addColumn: (SpStringTableColumn - title: '% Memory' - evaluated: [ :assoc | self convertToPercentageString: (assoc value sum: [ :e | e sizeInBytes ]) / totalMemory ]); - addColumn: (SpStringTableColumn - title: '# of allocated objects' - evaluated: [ :assoc | assoc value size asStringWithCommas ]); - addColumn: (SpStringTableColumn - title: '% Allocated objects' - evaluated: [ :assoc | self convertToPercentageString: (assoc value size / totalAllocations) ]); - yourself -] - -{ #category : 'accessing - model' } -FinalizationLifetimesTablePresenter >> setModelBeforeInitialization: someObjectAllocations [ +FinalizationLifetimesTablePresenter >> titleForGroupingColumn [ - groupedAllocationsBySeconds := (someObjectAllocations groupedBy: [ :allocationModel | - allocationModel lifetimeAsDuration asSeconds ]) associations. - groupedAllocationsBySeconds sort: [ :a :b | a key < b key ]. - totalMemory := groupedAllocationsBySeconds sum: [ :assoc | assoc value sum: [ :e | e sizeInBytes ] ]. - totalAllocations := groupedAllocationsBySeconds sum: [ :assoc | assoc value size ]. + ^ 'Lifetime duration (seconds)' ] diff --git a/src/IllimaniUI/FinalizationScavengesCyclesTablePresenter.class.st b/src/IllimaniUI/FinalizationScavengesCyclesTablePresenter.class.st new file mode 100644 index 0000000..a88e3e4 --- /dev/null +++ b/src/IllimaniUI/FinalizationScavengesCyclesTablePresenter.class.st @@ -0,0 +1,20 @@ +Class { + #name : 'FinalizationScavengesCyclesTablePresenter', + #superclass : 'AllocationsGroupedByTablePresenter', + #category : 'IllimaniUI-Widgets', + #package : 'IllimaniUI', + #tag : 'Widgets' +} + +{ #category : 'accessing - model' } +FinalizationScavengesCyclesTablePresenter >> groupAllocations: someObjectAllocations [ + + ^ (someObjectAllocations groupedBy: [ :allocationModel | + allocationModel survivedScavenges ]) associations +] + +{ #category : 'initialization' } +FinalizationScavengesCyclesTablePresenter >> titleForGroupingColumn [ + + ^ '# of scavenges survived' +] diff --git a/src/IllimaniUI/IllFinalizationProfilerUI.class.st b/src/IllimaniUI/IllFinalizationProfilerUI.class.st index 91a20b5..9f8ea3a 100644 --- a/src/IllimaniUI/IllFinalizationProfilerUI.class.st +++ b/src/IllimaniUI/IllFinalizationProfilerUI.class.st @@ -3,7 +3,8 @@ Class { #superclass : 'IllAbstractUI', #instVars : [ 'densityChartPresenter', - 'lifetimesTable' + 'lifetimesTable', + 'gcCyclesTable' ], #category : 'IllimaniUI-Main Presenter', #package : 'IllimaniUI', @@ -23,6 +24,13 @@ IllFinalizationProfilerUI >> densityChartPresenter [ ^ densityChartPresenter ] +{ #category : 'accessing - lazy presenters' } +IllFinalizationProfilerUI >> gcCyclesTable [ + + gcCyclesTable ifNil: [ self initializeGCCyclesTable ]. + ^ gcCyclesTable +] + { #category : 'initialization - lazy presenters' } IllFinalizationProfilerUI >> initializeDensityChartPresenter [ @@ -48,6 +56,17 @@ IllFinalizationProfilerUI >> initializeDensityChartPresenter [ yourself ] +{ #category : 'initialization - lazy presenters' } +IllFinalizationProfilerUI >> initializeGCCyclesTable [ + + gcCyclesTable := AlternatorPresenter new + presenterOne: (FinalizationScavengesCyclesTablePresenter on: profiler objectAllocations) + withName: 'Group by scavenges'; + presenterTwo: (FinalizationFullGCCyclesTablePresenter on: profiler objectAllocations) + withName: 'Group by full GCs'; + yourself +] + { #category : 'initialization - lazy presenters' } IllFinalizationProfilerUI >> initializeLifetimesTable [ @@ -61,8 +80,9 @@ IllFinalizationProfilerUI >> initializeNotebook [ notebookPresenter := self newNotebook addPageTitle: 'Summary' provider: [ self summaryAndEvaluatorPresenter ]; - addPageTitle: 'Allocated Objects' provider: [ self allocatedObjectsTablePresenter ]; addPageTitle: 'Lifetimes Table' provider: [ self lifetimesTable ]; + addPageTitle: 'Survived GC cycles' provider: [ self gcCyclesTable ]; + addPageTitle: 'Allocated Objects' provider: [ self allocatedObjectsTablePresenter ]; addPageTitle: 'Lifetimes Density' provider: [ self densityChartPresenter ]; addPageTitle: 'Evaluator' provider: [ self codeEvaluator ];