-
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 and refactor tests
- Loading branch information
1 parent
b91b4f2
commit 151bfb8
Showing
8 changed files
with
140 additions
and
143 deletions.
There are no files selected for viewing
89 changes: 89 additions & 0 deletions
89
src/IllimaniProfiler-Tests/IllAbstractProfilerTest.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,89 @@ | ||
Class { | ||
#name : 'IllAbstractProfilerTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'profiler' | ||
], | ||
#category : 'IllimaniProfiler-Tests-Finalization-Profiler', | ||
#package : 'IllimaniProfiler-Tests', | ||
#tag : 'Finalization-Profiler' | ||
} | ||
|
||
{ #category : 'testing' } | ||
IllAbstractProfilerTest class >> isAbstract [ | ||
|
||
^ self = IllAbstractProfilerTest | ||
] | ||
|
||
{ #category : 'running' } | ||
IllAbstractProfilerTest >> profilerClass [ | ||
|
||
^ self subclassResponsibility | ||
] | ||
|
||
{ #category : 'running' } | ||
IllAbstractProfilerTest >> setUp [ | ||
|
||
super setUp. | ||
profiler := self profilerClass new | ||
] | ||
|
||
{ #category : 'running' } | ||
IllAbstractProfilerTest >> tearDown [ | ||
|
||
profiler forceUninstall. | ||
profiler := nil. | ||
super tearDown | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAbstractProfilerTest >> testOpen [ | ||
"This is a smoke test" | ||
|
||
profiler profileOn: [ 5 timesRepeat: [ self profilerClass new ] ]. | ||
profiler open window close | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAbstractProfilerTest >> testProfileOnSimple [ | ||
|
||
profiler profileOn: [ 10 timesRepeat: [ IllFinalizationProfiler new ] ]. | ||
self assert: profiler objectAllocations size > 10 | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAbstractProfilerTest >> testSamplingRate [ | ||
|
||
| allocatedByteSrings | | ||
"Sampling is not enable for the moment" | ||
self flag: 'Skip'. | ||
self skip. | ||
|
||
profiler | ||
samplingRate: 33; | ||
profileOn: [ 90 timesRepeat: [ ByteString new ] ]. | ||
|
||
allocatedByteSrings := (profiler objectAllocations select: | ||
[ :e | e allocatedObjectClass = ByteString ]) size. | ||
|
||
"We are cheking in this range becase the profiler makes some allocations that are | ||
necessary for the profiler to work, like Durations objects. So we cannot chack that the | ||
allocations are exacty 1/3 of the total." | ||
self assert: (allocatedByteSrings >= 30) & (allocatedByteSrings < 40) | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAbstractProfilerTest >> testSamplingRateVariable [ | ||
|
||
"By default, do not sample" | ||
self assert: profiler samplingRate equals: 1. | ||
|
||
"Sample at 20%" | ||
profiler samplingRate: 20. | ||
"Sample at 20% is the same as sample each 5 allocations" | ||
self assert: profiler samplingRate equals: 5. | ||
|
||
"Do not sample. The same as sampling 100%". | ||
profiler samplingRate: 100. | ||
self assert: profiler samplingRate equals: 1. | ||
] |
79 changes: 10 additions & 69 deletions
79
src/IllimaniProfiler-Tests/IllAllocationProfilerTest.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 |
---|---|---|
@@ -1,97 +1,38 @@ | ||
Class { | ||
#name : 'IllAllocationProfilerTest', | ||
#superclass : 'TestCase', | ||
#instVars : [ | ||
'illimani' | ||
], | ||
#superclass : 'IllAbstractProfilerTest', | ||
#category : 'IllimaniProfiler-Tests-Allocations-Profiler', | ||
#package : 'IllimaniProfiler-Tests', | ||
#tag : 'Allocations-Profiler' | ||
} | ||
|
||
{ #category : 'running' } | ||
IllAllocationProfilerTest >> setUp [ | ||
IllAllocationProfilerTest >> profilerClass [ | ||
|
||
super setUp. | ||
illimani := IllAllocationProfiler new | ||
] | ||
|
||
{ #category : 'running' } | ||
IllAllocationProfilerTest >> tearDown [ | ||
|
||
illimani forceUninstall. | ||
illimani := nil. | ||
super tearDown | ||
^ IllAllocationProfiler | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAllocationProfilerTest >> testProfileOnCopyExecutionStack [ | ||
|
||
illimani | ||
profiler | ||
copyExecutionStack; | ||
profileOn: [ 10 timesRepeat: [ IllAllocationProfiler new ] ]. | ||
|
||
"Take one random allocation to check" | ||
self assert: illimani objectAllocations last context class equals: Context. | ||
self assert: profiler objectAllocations last context class equals: Context. | ||
|
||
self assert: illimani objectAllocations size > 100. | ||
illimani objectAllocations do: [ :alloc | "Stack was copied" | ||
self assert: profiler objectAllocations size > 100. | ||
profiler objectAllocations do: [ :alloc | "Stack was copied" | ||
self assert: alloc context class equals: Context ] | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAllocationProfilerTest >> testProfileOnSimple [ | ||
|
||
illimani profileOn: [ | ||
OrderedCollection new. | ||
OrderedCollection new. | ||
OrderedCollection new. | ||
Point new. | ||
Rectangle new ]. | ||
|
||
"Greater because the profiler makes 3 allocations" | ||
self assert: illimani objectAllocations size > 5 | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAllocationProfilerTest >> testProfileOnSimpleMoreAllocations [ | ||
|
||
illimani profileOn: [ 1000 timesRepeat: [ IllAllocationProfiler new ] ]. | ||
profiler profileOn: [ 1000 timesRepeat: [ IllAllocationProfiler new ] ]. | ||
|
||
self assert: illimani objectAllocations size > 1000. | ||
illimani objectAllocations do: [ :alloc | | ||
self assert: profiler objectAllocations size > 1000. | ||
profiler objectAllocations do: [ :alloc | | ||
self assert: alloc allocatedObjectClass isClass ] | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAllocationProfilerTest >> testSamplingRate [ | ||
|
||
| allocatedByteSrings | | ||
illimani | ||
samplingRate: 33; | ||
profileOn: [ 90 timesRepeat: [ ByteString new ] ]. | ||
|
||
allocatedByteSrings := (illimani objectAllocations select: | ||
[ :e | e allocatedObjectClass = ByteString ]) size. | ||
|
||
"We are cheking in this range becase the profiler makes some allocations that are | ||
necessary for the profiler to work, like Durations objects. So we cannot chack that the | ||
allocations are exacty 1/3 of the total." | ||
self assert: (allocatedByteSrings >= 30) & (allocatedByteSrings < 40) | ||
] | ||
|
||
{ #category : 'tests' } | ||
IllAllocationProfilerTest >> testSamplingRateVariable [ | ||
|
||
"By default, do not sample" | ||
self assert: illimani samplingRate equals: 1. | ||
|
||
"Sample at 20%" | ||
illimani samplingRate: 20. | ||
"Sample at 20% is the same as sample each 5 allocations" | ||
self assert: illimani samplingRate equals: 5. | ||
|
||
"Do not sample. The same as sampling 100%". | ||
illimani samplingRate: 100. | ||
self assert: illimani samplingRate equals: 1. | ||
] |
13 changes: 13 additions & 0 deletions
13
src/IllimaniProfiler-Tests/IllAllocationStatisticsProfilerTest.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,13 @@ | ||
Class { | ||
#name : 'IllAllocationStatisticsProfilerTest', | ||
#superclass : 'IllAbstractProfilerTest', | ||
#category : 'IllimaniProfiler-Tests-Finalization-Profiler', | ||
#package : 'IllimaniProfiler-Tests', | ||
#tag : 'Finalization-Profiler' | ||
} | ||
|
||
{ #category : 'running' } | ||
IllAllocationStatisticsProfilerTest >> profilerClass [ | ||
|
||
^ IllAllocationStatisticsProfiler | ||
] |
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
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
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