From 341b169f4ee3f3014541c6b19948dcde72c6cb05 Mon Sep 17 00:00:00 2001 From: jordanmontt Date: Mon, 23 Oct 2023 15:13:39 +0200 Subject: [PATCH] Fixing tests --- .../IllAllocationRateProfilerTest.class.st | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/IllimaniProfiler-Tests/IllAllocationRateProfilerTest.class.st b/src/IllimaniProfiler-Tests/IllAllocationRateProfilerTest.class.st index bf8f20a..179d83e 100644 --- a/src/IllimaniProfiler-Tests/IllAllocationRateProfilerTest.class.st +++ b/src/IllimaniProfiler-Tests/IllAllocationRateProfilerTest.class.st @@ -11,3 +11,39 @@ IllAllocationRateProfilerTest >> profilerClass [ ^ IllAllocationRateProfiler ] + +{ #category : 'tests' } +IllAllocationRateProfilerTest >> testSamplingRate [ + + | allocatedByteSrings | + + profiler + samplingRate: 33; + profileOn: [ 100 timesRepeat: [ ByteString new ] ]. + + "We don't have the classes on this profiler" + allocatedByteSrings := profiler objectAllocations 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 check that the + allocations are exacty 1/3 of the total." + self assert: (allocatedByteSrings >= 33) & (allocatedByteSrings < 40) +] + +{ #category : 'tests' } +IllAllocationRateProfilerTest >> testSamplingRateOtherPercentage [ + + | allocatedByteSrings | + + profiler + samplingRate: 75; + profileOn: [ 100 timesRepeat: [ ByteString new ] ]. + + "We don't have the class on this profiler" + allocatedByteSrings := profiler objectAllocations 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 >= 75) & (allocatedByteSrings < 80) +]