Skip to content

Commit

Permalink
Exporter: added lifetime average to the metadata. Separed the raw all…
Browse files Browse the repository at this point in the history
…ocations and the metadata in two methods. Now the user can export only the metadata.
  • Loading branch information
jordanmontt committed Apr 17, 2024
1 parent b405139 commit 1e93a76
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/IllimaniProfiler/IllAbstractExporter.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ Class {
}

{ #category : 'exporting' }
IllAbstractExporter >> exportAllocationModelCollection: fileName [
IllAbstractExporter >> exportAllocationModelCollection [

| writeStream writer |
| writeStream writer fileName |

baseFileName ifNil: [ baseFileName := self fileNameToExport ].
fileName := baseFileName , '.csv'.

writeStream := fileName asFileReference createFile writeStream.
writer := (NeoCSVWriter on: writeStream)
writeHeader: self headerOfAllocationModel;
Expand All @@ -31,8 +35,8 @@ IllAbstractExporter >> exportData [

baseFileName := self fileNameToExport.

self exportMetaData: baseFileName , '.json'.
self exportAllocationModelCollection: baseFileName , '.csv'.
self exportMetaData.
self exportAllocationModelCollection.
self exportGCActivity
]

Expand All @@ -43,15 +47,23 @@ IllAbstractExporter >> exportGCActivity [
]

{ #category : 'exporting' }
IllAbstractExporter >> exportMetaData: fileName [
IllAbstractExporter >> exportMetaData [

| tempDict jsonString writeStream avgLifetimes fileName |

baseFileName ifNil: [ baseFileName := self fileNameToExport ].
fileName := baseFileName , '.json'.

avgLifetimes := ((profiler objectAllocations sum: #lifetime)
/ profiler objectAllocations size) asFloat.

| tempDict jsonString writeStream |
tempDict := { ('totalExecutionTime' -> profiler totalTime).
('totalFullGCs' -> profiler totalFullGCs).
('profiledCode' -> profiler profiledCode).
('totalScavenges' -> profiler totalScavenges).
('samplingRate' -> profiler samplingRate).
('profiler' -> profiler class name) } asDictionary.
('profiler' -> profiler class name).
('averageLifetimes' -> avgLifetimes) } asDictionary.
jsonString := NeoJSONWriter toStringPretty: tempDict.

writeStream := fileName asFileReference createFile writeStream.
Expand Down
8 changes: 8 additions & 0 deletions src/IllimaniProfiler/IllAbstractProfiler.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,18 @@ IllAbstractProfiler >> beginningOfProfilingTime [

{ #category : 'exporting' }
IllAbstractProfiler >> exportData [
"This exports BOTH the metadata AND the raw allocations"

(self exporterClass on: self) exportData
]

{ #category : 'exporting' }
IllAbstractProfiler >> exportMetaData [
"This exports ONLY the medata data, not the raw allocations"

(self exporterClass on: self) exportMetaData
]

{ #category : 'exporting' }
IllAbstractProfiler >> exporterClass [

Expand Down

0 comments on commit 1e93a76

Please sign in to comment.