Skip to content

Commit

Permalink
Number of transactions as a env var
Browse files Browse the repository at this point in the history
  • Loading branch information
noonio committed Nov 13, 2024
1 parent 0a8e65b commit 6e6684a
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions hydra-node/bench/micro-bench/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit 6e6684a

Please sign in to comment.