-
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 tests for the finalization exporter
- Loading branch information
1 parent
b9b1ec0
commit 1a4a395
Showing
6 changed files
with
163 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Extension { #name : 'IllAbstractExporter' } | ||
|
||
{ #category : '*IllimaniProfiler-Tests' } | ||
IllAbstractExporter >> baseFileName [ | ||
|
||
^ baseFileName | ||
] |
68 changes: 68 additions & 0 deletions
68
src/IllimaniProfiler-Tests/IllFinalizationExporterTest.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 @@ | ||
" | ||
An IllFinalizationExporterTest is a test class for testing the behavior of IllFinalizationExporter | ||
" | ||
Class { | ||
#name : 'IllFinalizationExporterTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'exporter', | ||
'header', | ||
'mockProfiler', | ||
'mockGCMonitor' | ||
], | ||
#category : 'IllimaniProfiler-Tests', | ||
#package : 'IllimaniProfiler-Tests' | ||
} | ||
|
||
{ #category : 'running' } | ||
IllFinalizationExporterTest >> fakeAllocations [ | ||
|
||
| allocatedClasses | | ||
allocatedClasses := 'Kernel' asPackage definedClasses asArray first: 10. | ||
^ (1 to: 1000) collect: [ :i | IllEphemeron new | ||
allocatedObjectClass: allocatedClasses atRandom; | ||
sizeInBytes: 100; | ||
finalizationTime: Time primUTCMicrosecondsClock; | ||
updateStatistics; | ||
yourself ] | ||
] | ||
|
||
{ #category : 'running' } | ||
IllFinalizationExporterTest >> setUp [ | ||
|
||
super setUp. | ||
mockGCMonitor := IllMockGCMonitor new. | ||
mockProfiler := IllMockProfiler new | ||
objectAllocations: self fakeAllocations; | ||
gcMonitor: mockGCMonitor; | ||
yourself. | ||
exporter := IllFinalizationExporter new | ||
profiler: mockProfiler; | ||
yourself | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllFinalizationExporterTest >> testExportData [ | ||
|
||
| readStream csvReader actualHeader line createdFile | | ||
header := #( 'finalizationTimeInMicroSeconds' 'sizeInBytes' 'initializationTimeInMicroSeconds' | ||
'allocatedObjectClass' 'survivedScavenges' 'survivedFullGCs' 'forcedFinalization' ). | ||
exporter exportData. | ||
|
||
createdFile := (exporter baseFileName , '.csv') asFileReference. | ||
self assert: createdFile exists. | ||
|
||
readStream := createdFile readStream. | ||
csvReader := NeoCSVReader on: readStream. | ||
|
||
actualHeader := csvReader next. | ||
line := csvReader next. | ||
|
||
self assert: header equals: actualHeader. | ||
self assert: line first asInteger > 100000000. | ||
self assert: line second asInteger equals: 100 "size". | ||
self assert: (line fourth asClassInEnvironment:Smalltalk globals) isClass. | ||
self assert: line last equals: 'false'. | ||
|
||
createdFile delete | ||
] |
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,13 @@ | ||
Class { | ||
#name : 'IllMockGCMonitor', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'allocations' | ||
], | ||
#category : 'IllimaniProfiler-Tests', | ||
#package : 'IllimaniProfiler-Tests' | ||
} | ||
|
||
{ #category : 'exporting' } | ||
IllMockGCMonitor >> exportData: baseFileName [ | ||
] |
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,64 @@ | ||
Class { | ||
#name : 'IllMockProfiler', | ||
#superclass : 'Object', | ||
#instVars : [ | ||
'allocations', | ||
'gcMonitor' | ||
], | ||
#category : 'IllimaniProfiler-Tests', | ||
#package : 'IllimaniProfiler-Tests' | ||
} | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> gcActivityMonitor [ | ||
|
||
^ gcMonitor | ||
] | ||
|
||
{ #category : 'as yet unclassified' } | ||
IllMockProfiler >> gcMonitor: anIllMockGCMonitor [ | ||
|
||
gcMonitor := anIllMockGCMonitor | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> objectAllocations [ | ||
|
||
^ allocations | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> objectAllocations: aCollection [ | ||
|
||
allocations := aCollection | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> profiledCode [ | ||
|
||
^ 'TestProfiler testTheProfiler' | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> samplingRate [ | ||
|
||
^ 100 | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> totalFullGCs [ | ||
|
||
^ 2 | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> totalScavenges [ | ||
|
||
^ 156 | ||
] | ||
|
||
{ #category : 'accessing' } | ||
IllMockProfiler >> totalTime [ | ||
|
||
^ 2000000 "2 microseconds" | ||
] |
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