Verified Commit 0d110ed4 authored by Camil Staps's avatar Camil Staps 🚀

Update MemoryLeaks test

parent 8291ce34
Pipeline #47650 passed with stages
in 9 minutes and 10 seconds
......@@ -18,44 +18,40 @@ repetitions =: 1000
tests :: [UnitTest]
tests =:
[ memoryConsumptionOf "recursive step" recursiveStep
, memoryConsumptionOf "local share" localShare
, memoryConsumptionOf "parallel task" parallelTask
, memoryConsumptionOf "shared interaction task" sharedInteraction
[ memoryConsumptionOf "recursive step" getIWorldSize
, memoryConsumptionOf "local share" (withShared 3 \_ -> getIWorldSize)
, memoryConsumptionOf "parallel task" (viewInformation [] 3 ||- getIWorldSize)
, memoryConsumptionOf "shared interaction task" (withShared 3 \sds -> viewSharedInformation [] sds ||- getIWorldSize)
]
recursiveStep :: Task [Int]
recursiveStep =: sequence $ repeatn repetitions getIWorldSize
localShare :: Task [Int]
localShare =: sequence $ repeatn repetitions (withShared 3 \_ -> getIWorldSize)
parallelTask :: Task [Int]
parallelTask =: sequence $ repeatn repetitions (viewInformation [] 3 ||- getIWorldSize)
sharedInteraction :: Task [Int]
sharedInteraction =:
sequence $ repeatn repetitions (withShared 3 \sds -> viewSharedInformation [] sds ||- getIWorldSize)
memoryConsumptionOf :: !String !(Task [Int]) -> UnitTest
memoryConsumptionOf :: !String !(Task Int) -> UnitTest
memoryConsumptionOf label task =
testTaskResult
("memory consumption of " +++ label) task events [] iWorldSizeIsNotIncreasing
("memory consumption of " +++ label) (seqTask 0 (Left [])) events (0,0) iWorldSizeIsNotIncreasing
where
events = [Left ResetEvent]
iWorldSizeIsNotIncreasing :: [Int] ![Int] -> EndEventType
iWorldSizeIsNotIncreasing _ iWorldSizes
// Because sizes are not entirely stable, we take the maximum of the initial 10% IWorld sizes as the initial value.
// When the value is Left, we are still collecting the first 10% of values to determine the initial IWorld size.
// When the value is Right, we have the initial IWorld size and are updating only the final IWorld size.
seqTask i (Left sizes) =
task >>- \sz
| i >= repetitions / 10
-> seqTask (i+1) (Right (maxList [sz:sizes], sz))
-> seqTask (i+1) (Left [sz:sizes])
seqTask i (Right result=:(initSize,endSize))
| i >= repetitions
= return result
= task >>- \sz -> seqTask (i+1) (Right (initSize, sz))
iWorldSizeIsNotIncreasing :: a !(!Int,!Int) -> EndEventType
iWorldSizeIsNotIncreasing _ (initSize,endSize)
| endSize <= initSize = Passed
| otherwise =
Failed $
?Just $
CustomFailReason $
concat ["Memory consumption increased by ", toString $ endSize - initSize, " bytes."]
where
// As there is some variation in the size, we use the max of the first 10% of the sizes as initial value.
initSize = 'DF'.maximum $ take (repetitions / 10) iWorldSizes
endSize = last iWorldSizes
getIWorldSize :: Task Int
getIWorldSize = mkInstantTask \_ iworld
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment