-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added new profiler to get the allocation rate
- Loading branch information
1 parent
247e55e
commit b91b4f2
Showing
10 changed files
with
269 additions
and
138 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
Class { | ||
#name : 'AllocationBasicInfoModel', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'allocatedObjectClass', | ||
'sizeInBytes' | ||
], | ||
#category : 'IllimaniProfiler-Model-Allocation', | ||
#package : 'IllimaniProfiler', | ||
#tag : 'Model-Allocation' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
AllocationBasicInfoModel >> allocatedObjectClass [ | ||
|
||
^ allocatedObjectClass | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationBasicInfoModel >> allocatedObjectClass: anObject [ | ||
|
||
allocatedObjectClass := anObject | ||
] | ||
|
||
{ #category : 'inspector - extensions' } | ||
AllocationBasicInfoModel >> inspectableAssociations [ | ||
|
||
^ { | ||
('Allocated Object Class' -> allocatedObjectClass). | ||
('Memory Size' -> sizeInBytes humanReadableByteSizeString) } | ||
] | ||
|
||
{ #category : 'inspector - extensions' } | ||
AllocationBasicInfoModel >> inspectorExtension: aBuilder [ | ||
|
||
<inspectorPresentationOrder: 0 title: 'Overview'> | ||
| tablePresenter elements items | | ||
elements := self inspectableAssociations. | ||
items := elements collect: [ :e | StInspectorAssociationNode hostObject: e ]. | ||
tablePresenter := aBuilder newTable. | ||
tablePresenter | ||
addColumn: (SpStringTableColumn title: 'Name' evaluated: #key); | ||
addColumn: (SpStringTableColumn title: 'Value' evaluated: #value); | ||
items: items; | ||
beResizable. | ||
^ tablePresenter | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationBasicInfoModel >> sizeInBytes [ | ||
"Returns the size in memory in bytes" | ||
|
||
^ sizeInBytes | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationBasicInfoModel >> sizeInBytes: aNumber [ | ||
|
||
sizeInBytes := aNumber | ||
] |
79 changes: 79 additions & 0 deletions
79
src/IllimaniProfiler/AllocationFinalizationInfoModel.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
Class { | ||
#name : 'AllocationFinalizationInfoModel', | ||
#superclass : 'AllocationBasicInfoModel', | ||
#instVars : [ | ||
'finalizationTime', | ||
'initializationTime' | ||
], | ||
#category : 'IllimaniProfiler-Model-Allocation', | ||
#package : 'IllimaniProfiler', | ||
#tag : 'Model-Allocation' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> finalizationTime [ | ||
"In microseconds" | ||
|
||
^ finalizationTime | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> finalizationTime: anObject [ | ||
"In microseconds" | ||
|
||
finalizationTime := anObject | ||
] | ||
|
||
{ #category : 'finalization' } | ||
AllocationFinalizationInfoModel >> finalize [ | ||
|
||
finalizationTime := Time microsecondClockValue | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> initializationTime [ | ||
"In microseconds" | ||
|
||
^ initializationTime | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> initializationTime: microsecondsAsInt [ | ||
"In microseconds" | ||
|
||
initializationTime := microsecondsAsInt | ||
] | ||
|
||
{ #category : 'inspector - extensions' } | ||
AllocationFinalizationInfoModel >> inspectableAssociations [ | ||
|
||
^ super inspectableAssociations , { | ||
('Initialization timestamp' -> initializationTime). | ||
('Finalization timestamp' -> finalizationTime). | ||
('Object''s lifetime' -> self lifetimeAsString) } | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> lifetime [ | ||
|
||
^ finalizationTime - initializationTime | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> lifetimeAsDuration [ | ||
|
||
^ Duration microSeconds: self lifetime | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> lifetimeAsString [ | ||
|
||
finalizationTime ifNil: [ ^ '-' ]. | ||
^ self lifetimeAsDuration humanReadablePrintString | ||
] | ||
|
||
{ #category : 'accessing' } | ||
AllocationFinalizationInfoModel >> timeAsSeconds [ | ||
|
||
^ initializationTime / 1000000 | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
68 changes: 68 additions & 0 deletions
68
src/IllimaniProfiler/IllAllocationStatisticsProfiler.class.st
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
Class { | ||
#name : 'IllAllocationStatisticsProfiler', | ||
#superclass : 'IllAbstractProfiler', | ||
#instVars : [ | ||
'allocationsRegistry', | ||
'objectAllocations' | ||
], | ||
#category : 'IllimaniProfiler-Allocation-Profiler', | ||
#package : 'IllimaniProfiler', | ||
#tag : 'Allocation-Profiler' | ||
} | ||
|
||
{ #category : 'accessing - statistics' } | ||
IllAllocationStatisticsProfiler >> allocatedMemoryRatePerSecond [ | ||
|
||
^ self stats totalAllocatedMemory | ||
/ (Duration microSeconds: totalTime) totalSeconds asFloat | ||
] | ||
|
||
{ #category : 'accessing - statistics' } | ||
IllAllocationStatisticsProfiler >> allocationRatePerSecond [ | ||
|
||
^ self stats totalAllocatedObjects | ||
/ (Duration microSeconds: totalTime) totalSeconds asFloat | ||
] | ||
|
||
{ #category : 'initialization' } | ||
IllAllocationStatisticsProfiler >> initialize [ | ||
|
||
super initialize. | ||
allocationsRegistry := OrderedCollection new: 3000000 | ||
] | ||
|
||
{ #category : 'profiling' } | ||
IllAllocationStatisticsProfiler >> internalRegisterAllocation: anObject [ | ||
|
||
allocationsRegistry add: anObject class -> anObject sizeInMemory | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllAllocationStatisticsProfiler >> objectAllocations [ | ||
|
||
objectAllocations ifNil: [ | ||
objectAllocations := allocationsRegistry collect: [ :assoc | | ||
AllocationBasicInfoModel new | ||
allocatedObjectClass: assoc key; | ||
sizeInBytes: assoc value; | ||
yourself ] ]. | ||
^ objectAllocations | ||
] | ||
|
||
{ #category : 'accessing - statistics' } | ||
IllAllocationStatisticsProfiler >> stats [ | ||
|
||
^ self | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllAllocationStatisticsProfiler >> totalAllocatedMemory [ | ||
|
||
^ self objectAllocations sum: #sizeInBytes | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllAllocationStatisticsProfiler >> totalAllocatedObjects [ | ||
|
||
^ allocationsRegistry size | ||
] |
Oops, something went wrong.