Skip to content

Commit

Permalink
Added predictor [experimental]
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanmontt committed Sep 20, 2024
1 parent 5a048f7 commit e112559
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/IllimaniProfiler/IllPredictator.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
Class {
#name : 'IllPredictator',
#superclass : 'Object',
#instVars : [
'objectAllocations',
'predictors'
],
#category : 'IllimaniProfiler-Analyzer',
#package : 'IllimaniProfiler',
#tag : 'Analyzer'
}

{ #category : 'as yet unclassified' }
IllPredictator >> computePredictors [

predictors := Dictionary new.

objectAllocations do: [ :illEphe |
predictors
at: illEphe allocationSite
ifPresent: [ :predictor |
predictor
addLifetime: illEphe lifetime;
addType: illEphe allocatedObjectClass ]
ifAbsentPut: [
IllPredictor new
allocationSite: illEphe allocationSite;
addLifetime: illEphe lifetime;
addType: illEphe allocatedObjectClass ] ]
]

{ #category : 'accessing' }
IllPredictator >> objectAllocations: aCollection [

objectAllocations := aCollection
]
40 changes: 40 additions & 0 deletions src/IllimaniProfiler/IllPredictor.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Class {
#name : 'IllPredictor',
#superclass : 'Object',
#instVars : [
'allocationSite',
'lifetimes',
'types'
],
#category : 'IllimaniProfiler-Analyzer',
#package : 'IllimaniProfiler',
#tag : 'Analyzer'
}

{ #category : 'adding' }
IllPredictor >> addLifetime: anInteger [

| normalizedNumber |
normalizedNumber := (anInteger log: 2) > 20 "because 2 ^ 20 is 1 MB"
ifTrue: [ (anInteger log: 2) floor ]
ifFalse: [ 0 ].
lifetimes add: normalizedNumber
]

{ #category : 'adding' }
IllPredictor >> addType: aClass [
types add: aClass
]

{ #category : 'accessing' }
IllPredictor >> allocationSite: anIllAllocationSite [
allocationSite := anIllAllocationSite
]

{ #category : 'initialization' }
IllPredictor >> initialize [

super initialize.
lifetimes := Bag new.
types := Bag new
]

0 comments on commit e112559

Please sign in to comment.