@@ -54,31 +54,35 @@ main = withStdTerminalHandles $ do
5454 where
5555 benchAddNTxs n =
5656 withResource
57- (pure $!! mkNTryAddTxs n)
57+ (pure $!!
58+ let cmds = mkNTryAddTxs n
59+ sz = sum $ map TestBlock. txSize $ getCmdsTxs cmds
60+ in (cmds, Mempool. ByteSize sz)
61+ )
5862 (\ _ -> pure () )
59- (\ getTxs -> do
63+ (\ getCmds -> do
6064 bgroup (show n <> " transactions" ) [
6165 bench " setup mempool" $ whnfIO $ do
62- txs <- getTxs
63- openMempoolWithCapacityFor txs
66+ (_cmds, capacity) <- getCmds
67+ openMempoolWithCapacity capacity
6468 , bench " setup mempool + benchmark" $ whnfIO $ do
65- txs <- getTxs
66- mempool <- openMempoolWithCapacityFor txs
67- run mempool txs
69+ (cmds, capacity) <- getCmds
70+ mempool <- openMempoolWithCapacity capacity
71+ run mempool cmds
6872 , testCase " test" $ do
69- txs <- getTxs
70- mempool <- openMempoolWithCapacityFor txs
71- testAddTxs mempool txs
72- , testCase " txs length" $ do
73- txs <- getTxs
74- length txs @?= n
73+ (cmds, capacity) <- getCmds
74+ mempool <- openMempoolWithCapacity capacity
75+ testAddCmds mempool cmds
76+ , testCase " cmds length" $ do
77+ (cmds, _capacity) <- getCmds
78+ length cmds @?= n
7579 ]
7680 )
7781 where
78- testAddTxs mempool txs = do
79- run mempool txs
82+ testAddCmds mempool cmds = do
83+ run mempool cmds
8084 mempoolTxs <- Mocked. getTxs mempool
81- mempoolTxs @?= getCmdsTxs txs
85+ mempoolTxs @?= getCmdsTxs cmds
8286
8387 parseBenchmarkResults csvFilePath = do
8488 csvData <- BL. readFile csvFilePath
@@ -129,18 +133,17 @@ main = withStdTerminalHandles $ do
129133 Adding TestBlock transactions to a mempool
130134-------------------------------------------------------------------------------}
131135
132- openMempoolWithCapacityFor :: [MempoolCmd TestBlock ] -> IO (MockedMempool IO TestBlock )
133- openMempoolWithCapacityFor cmds =
134- Mocked. openMockedMempool capacityRequiredByCmds
136+ openMempoolWithCapacity :: Mempool. ByteSize -> IO (MockedMempool IO TestBlock )
137+ openMempoolWithCapacity capacity =
138+ Mocked. openMockedMempool (Mempool. mkCapacityBytesOverride
139+ (Mempool. unByteSize capacity)
140+ )
135141 Tracer. nullTracer
136142 TestBlock. txSize
137143 Mocked. MempoolAndModelParams {
138144 Mocked. immpInitialState = TestBlock. initialLedgerState
139145 , Mocked. immpLedgerConfig = TestBlock. sampleLedgerConfig
140146 }
141- where
142- capacityRequiredByCmds = Mempool. mkCapacityBytesOverride totalTxsSize
143- where totalTxsSize = sum $ fmap TestBlock. txSize $ getCmdsTxs cmds
144147
145148mkNTryAddTxs :: Int -> [MempoolCmd TestBlock. TestBlock ]
146149mkNTryAddTxs 0 = []
0 commit comments