11{-# LANGUAGE BlockArguments #-}
22{-# LANGUAGE LambdaCase #-}
3+ {-# LANGUAGE MultiWayIf #-}
34{-# LANGUAGE NumericUnderscores #-}
45{-# LANGUAGE RecordWildCards #-}
56
@@ -15,7 +16,7 @@ import Cardano.Benchmarking.Script.Action
1516import Cardano.Benchmarking.Script.Aeson (parseScriptFileAeson )
1617import Cardano.Benchmarking.Script.Core (setProtocolParameters )
1718import qualified Cardano.Benchmarking.Script.Env as Env (ActionM , Env (.. ), Error ,
18- getEnvThreads , runActionMEnv , traceError )
19+ getEnvThreads , runActionMEnv , traceDebug , traceError )
1920import Cardano.Benchmarking.Script.Types
2021
2122import Prelude
@@ -35,6 +36,17 @@ type Script = [Action]
3536-- 'Ogmios') never create one, in which case it is 'Nothing'.
3637runScript :: Env. Env -> Script -> EnvConsts -> IO (Either Env. Error () , Maybe AsyncBenchmarkControl )
3738runScript env script constants@ EnvConsts { .. } = do
39+ -- Plain 'putStrLn', not a trace: this runs before the script's own
40+ -- 'StartProtocol' action (if it even has one), so BenchTracers are
41+ -- not yet constructed.
42+ putStrLn $ " This workload script will generate " ++
43+ ( let count = countScriptTxns script in
44+ if
45+ | count == 0 -> " no transactions"
46+ | count == maxBound -> " an infinite stream of transactions"
47+ | count == (- 1 ) -> " an unknown number of transactions (stream is non-deterministic)"
48+ | otherwise -> " a finite stream yielding " ++ show count ++ " transactions"
49+ )
3850 result <- go
3951 performGC
4052 threadDelay $ 150 * 1_000
@@ -60,5 +72,31 @@ runScript env script constants@EnvConsts { .. } = do
6072
6173shutDownLogging :: Env. ActionM ()
6274shutDownLogging = do
63- Env. traceError " QRT Last Message. LoggingLayer shutting down ..."
75+ Env. traceDebug " QRT Last Message. LoggingLayer shutting down ..."
6476 liftIO $ threadDelay $ 350 * 1_000
77+
78+ -- Results:
79+ -- (-1): somwhere in [0..Infinity] due to use of non-deterministic generator combinator
80+ -- maxBound: infinite txn stream
81+ -- n: finite stream of n txns
82+ countScriptTxns :: Script -> Int
83+ countScriptTxns = sum . map actionTxCount
84+ where
85+ actionTxCount = \ case
86+ Submit _ _ _ gen -> genTxCount gen
87+ _ -> 0
88+ genTxCount = \ case
89+ SecureGenesis {} -> 1
90+ Split {} -> 1
91+ SplitN {} -> 1
92+ NtoM {} -> 1
93+ Cycle g -> if genTxCount g < 0 then (- 1 ) else maxBound
94+ Take i g -> min i (genTxCount g)
95+ Sequence gs -> guardedSum $ map genTxCount gs
96+ RoundRobin gs -> guardedSum $ map genTxCount gs
97+ OneOf {} -> (- 1 ) -- is non-deterministic
98+ where
99+ guardedSum is
100+ | any (< 0 ) is = - 1
101+ | maxBound `elem` is = maxBound
102+ | otherwise = sum is
0 commit comments