From 6e6684a0f00ce65e04bb8abce2b88bce4b456765 Mon Sep 17 00:00:00 2001 From: Noon van der Silk Date: Wed, 13 Nov 2024 11:52:47 +0000 Subject: [PATCH] Number of transactions as a env var --- hydra-node/bench/micro-bench/Main.hs | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/hydra-node/bench/micro-bench/Main.hs b/hydra-node/bench/micro-bench/Main.hs index 6906bf15860..583ce9eca66 100644 --- a/hydra-node/bench/micro-bench/Main.hs +++ b/hydra-node/bench/micro-bench/Main.hs @@ -20,7 +20,12 @@ import Test.QuickCheck (generate) main :: IO () main = do - (utxo, tx) <- prepareTx + -- Use this env var to run benchmarks for more transations: + -- + -- > N_TXNS=100000 cabal bench micro --benchmark-options '+RTS -T' + -- + nTxns <- fromMaybe 1 . (>>= readMaybe) <$> lookupEnv "N_TXNS" + (utxo, tx) <- prepareTx nTxns let jsonNewTx = (Aeson.encode . NewTx) tx toNewTx bs = object ["tag" .= ("NewTx" :: Text), "transaction" .= String (decodeUtf8 bs)] cborNewTx = (Aeson.encode . toNewTx . serialiseToCBOR) tx @@ -35,9 +40,9 @@ main = do ] ] -prepareTx :: IO (UTxO, Tx) -prepareTx = - second List.head <$> generate (genFixedSizeSequenceOfSimplePaymentTransactions 4_000_000) +prepareTx :: Int -> IO (UTxO, Tx) +prepareTx n = + second List.head <$> generate (genFixedSizeSequenceOfSimplePaymentTransactions n) benchApplyTxs :: (UTxO, Tx) -> Either (Tx, ValidationError) UTxO benchApplyTxs (utxo, tx) = applyTransactions defaultLedger (ChainSlot 1) utxo [tx]