From 5afe45abde62308eda1de7a2b6c3d30f5acf1686 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Thu, 18 Jan 2024 13:58:21 +0100 Subject: [PATCH] Added exporting methods to export the finalization profiler data to csv --- src/IllimaniProfiler/IllEphemeron.class.st | 20 +++++++++++++++++++ .../IllFinalizationProfiler.class.st | 15 ++++++++++++++ 2 files changed, 35 insertions(+) diff --git a/src/IllimaniProfiler/IllEphemeron.class.st b/src/IllimaniProfiler/IllEphemeron.class.st index f4601e9..b30eb47 100644 --- a/src/IllimaniProfiler/IllEphemeron.class.st +++ b/src/IllimaniProfiler/IllEphemeron.class.st @@ -40,6 +40,19 @@ IllEphemeron >> finalizationTime: anObject [ finalizationTime := anObject ] +{ #category : 'serialization' } +IllEphemeron >> flatInstanceVariables [ + + ^ { + finalizationTime asString. + sizeInBytes asString. + initializationTime asString. + allocatedObjectClass asString. + survivedScavenges asString. + survivedFullGC asString. + forcedFinalization asString } +] + { #category : 'finalization' } IllEphemeron >> forceFinalization [ @@ -56,6 +69,13 @@ IllEphemeron >> forcedFinalization [ ^ forcedFinalization ] +{ #category : 'serialization' } +IllEphemeron >> headerToExportCSV [ + + ^ #( #finalizationTime #sizeInBytes #initializationTime #allocatedObjectClass + #survivedScavenges #survivedFullGC #forcedFinalization ) +] + { #category : 'accessing' } IllEphemeron >> initializationTime [ diff --git a/src/IllimaniProfiler/IllFinalizationProfiler.class.st b/src/IllimaniProfiler/IllFinalizationProfiler.class.st index 395bcbf..2f8ba68 100644 --- a/src/IllimaniProfiler/IllFinalizationProfiler.class.st +++ b/src/IllimaniProfiler/IllFinalizationProfiler.class.st @@ -11,6 +11,21 @@ Class { #tag : 'Finalization-Profiler' } +{ #category : 'serialization' } +IllFinalizationProfiler >> exportData [ + + | writer csvFile fileName | + fileName := DateAndTime now asString , '.csv'. + csvFile := fileName asFileReference createFile writeStream. + writer := NeoCSVWriter on: csvFile. + writer writeHeader: ephemeronsCollection first headerToExportCSV. + + ephemeronsCollection do: [ :anIllEphemeron | + writer nextPut: anIllEphemeron flatInstanceVariables ]. + + writer close +] + { #category : 'profiling' } IllFinalizationProfiler >> forceFinalizationOfObjects [