pretty print

This commit is contained in:
Seungheon Oh 2022-05-25 14:52:33 -05:00
parent 15d58323a9
commit 7457c6334b
No known key found for this signature in database
GPG key ID: 9B0E12D357369B66
4 changed files with 34 additions and 30 deletions

View file

@ -8,12 +8,12 @@ import Data.ByteString.Short qualified as SBS
import Data.Csv (DefaultOrdered, ToNamedRecord, header, headerOrder, namedRecord, toNamedRecord, (.=))
import Data.List (intercalate)
import Data.Maybe (fromJust)
import Data.Text (Text, pack)
import Data.Text (Text, pack, unpack)
import GHC.Generics (Generic)
import Plutus.V1.Ledger.Api (
ExBudget (ExBudget),
ExCPU,
ExMemory,
ExCPU (..),
ExMemory (..),
Script,
)
import Plutus.V1.Ledger.Api qualified as Plutus
@ -37,7 +37,11 @@ data Benchmark = Benchmark
, scriptSize :: Int
-- ^ The on-chain size of a script.
}
deriving stock (Show, Eq, Ord, Generic)
deriving stock (Eq, Ord, Generic)
instance Show Benchmark where
show (Benchmark name (ExCPU cpu) (ExMemory mem) size) =
unpack name <> "\n\tCPU: " <> show cpu <> " MEM: " <> show mem <> " SIZE: " <> show size
instance ToNamedRecord Benchmark where
toNamedRecord (Benchmark {..}) =

View file

@ -21,12 +21,12 @@ main = do
I.writeFile "bench.csv" $
(decodeUtf8 . encodeDefaultOrderedByName) res
mapM_ print res
mapM_ (Prelude.putStrLn . (<> "\n") . show) res
where
res =
specificationTreeToBenchmarks $
group
"Benchmark"
"Agora"
[ group
"Effects"
[ group "Treasury Withdrawal Effect" TreasuryWithdrawal.specs