Commit 8d07cd0c authored by Steffen Michels's avatar Steffen Michels

Merge branch 'fix-memoryleaks-test' into 'master'

Fix MemoryLeaks test

See merge request !533
parents 7e942348 71d5da7b
Pipeline #48009 passed with stages
in 10 minutes and 48 seconds
......@@ -9,7 +9,8 @@ import qualified Data.Map as Map
import Text
import Testing.TestEvents
import graph_copy
import iTasks, iTasks.Testing.Unit, iTasks.Internal.Task, iTasks.Internal.TaskIO
import iTasks, iTasks.Testing.Unit
import iTasks.Internal.IWorld, iTasks.Internal.Task, iTasks.Internal.TaskIO
Start world = runUnitTests tests world
......@@ -53,8 +54,16 @@ where
CustomFailReason $
concat ["Memory consumption increased by ", toString $ endSize - initSize, " bytes."]
/* NB: We subtract the size of the names of shares. Because share names include
* TaskIds in string representation, and these IDs are incremented, including
* share names may cause the IWorld size to increase; we want to ignore these
* small changes.
*/
getIWorldSize :: Task Int
getIWorldSize = mkInstantTask \_ iworld
getIWorldSize = mkInstantTask \_ iworld=:{memoryShares}
# iworldString = copy_to_string iworld
# (iworldSize, iworldString) = usize iworldString
-> (Ok iworldSize, fst $ copy_from_string iworldString)
# (iworldSize,iworldString) = usize iworldString
# (iworld,_) = copy_from_string iworldString
# shareNamesSize = 'Map'.foldrWithKey` (\k _ n -> n + size (copy_to_string k)) 0 memoryShares
// We cannot simply fold with `size k` due to padding in `copy_to_string`.
-> (Ok (iworldSize - shareNamesSize), 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