CSV would be better than JSON
This commit is contained in:
parent
ad957d6b02
commit
a74a98c206
4 changed files with 41 additions and 22 deletions
|
|
@ -1,12 +1,15 @@
|
|||
{-# LANGUAGE RecordWildCards #-}
|
||||
|
||||
module Bench (Benchmark (..), benchmarkScript, specificationTreeToBenchmarks) where
|
||||
|
||||
import Codec.Serialise (serialise)
|
||||
import Data.Aeson hiding (Success)
|
||||
import Data.ByteString.Lazy qualified as LBS
|
||||
import Data.ByteString.Short qualified as SBS
|
||||
import Data.Csv (ToNamedRecord, DefaultOrdered, toNamedRecord, namedRecord, header, headerOrder, (.=))
|
||||
import Data.List (intercalate)
|
||||
import Data.Maybe (fromJust)
|
||||
import Data.Text (Text, pack)
|
||||
import GHC.Generics (Generic)
|
||||
import Plutus.V1.Ledger.Api (
|
||||
ExBudget (ExBudget),
|
||||
ExCPU,
|
||||
|
|
@ -34,25 +37,20 @@ data Benchmark = Benchmark
|
|||
, bScriptSize :: Int
|
||||
-- ^ The on-chain size of a script.
|
||||
}
|
||||
deriving stock (Show, Eq, Ord)
|
||||
deriving stock (Show, Eq, Ord, Generic)
|
||||
|
||||
instance FromJSON Benchmark where
|
||||
parseJSON (Object v) =
|
||||
Benchmark <$> v .: "name"
|
||||
<*> v .: "cpu"
|
||||
<*> v .: "mem"
|
||||
<*> v .: "size"
|
||||
parseJSON _ = mempty
|
||||
|
||||
instance ToJSON Benchmark where
|
||||
toJSON (Benchmark name cpu mem size) =
|
||||
object
|
||||
instance ToNamedRecord Benchmark where
|
||||
toNamedRecord (Benchmark {..}) =
|
||||
namedRecord
|
||||
[ "name" .= name
|
||||
, "cpu" .= cpu
|
||||
, "mem" .= mem
|
||||
, "size" .= size
|
||||
, "cpu" .= bCPUBudget
|
||||
, "mem" .= bMemoryBudget
|
||||
, "size" .= bScriptSize
|
||||
]
|
||||
|
||||
instance DefaultOrdered Benchmark where
|
||||
headerOrder _ = header ["name", "cpu", "mem", "size"]
|
||||
|
||||
benchmarkScript :: String -> Script -> Benchmark
|
||||
benchmarkScript name script = Benchmark (pack name) cpu mem size
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
module Main (main) where
|
||||
|
||||
import Bench (specificationTreeToBenchmarks)
|
||||
import Data.Aeson.Text (encodeToLazyText)
|
||||
import Data.Csv (encodeDefaultOrderedByName)
|
||||
import Data.Text.Lazy.Encoding (decodeUtf8)
|
||||
import Data.Text.Lazy.IO as I
|
||||
import Spec.AuthorityToken qualified as AuthorityToken
|
||||
import Spec.Effect.GovernorMutation qualified as GovernorMutation
|
||||
|
|
@ -17,8 +18,8 @@ import Prelude
|
|||
|
||||
main :: IO ()
|
||||
main = do
|
||||
I.writeFile "bench.json" $
|
||||
encodeToLazyText $
|
||||
I.writeFile "bench.csv" $
|
||||
(decodeUtf8 . encodeDefaultOrderedByName) $
|
||||
specificationTreeToBenchmarks $
|
||||
group
|
||||
"Benchmark"
|
||||
|
|
|
|||
|
|
@ -218,6 +218,7 @@ benchmark agora-bench
|
|||
, agora
|
||||
, agora-sample
|
||||
, agora-spec
|
||||
, cassava
|
||||
|
||||
executable agora-scripts
|
||||
import: lang, deps, exe-opts
|
||||
|
|
|
|||
25
bench.csv
25
bench.csv
|
|
@ -1,4 +1,23 @@
|
|||
name,cpu,mem,size
|
||||
full_scripts:authorityTokenPolicy,1756707,6000,841
|
||||
full_scripts:stakePolicy,3751498,12700,1610
|
||||
full_scripts:stakeValidator,3126265,10600,1500
|
||||
Benchmark/Effects/Treasury Withdrawal Effect/effect/Simple,340268715,724428,3050
|
||||
Benchmark/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,570029812,1211300,3377
|
||||
Benchmark/Effects/Treasury Withdrawal Effect/effect/Mixed Assets,502351827,1071087,3242
|
||||
Benchmark/Effects/Governor Mutation Effect/validator/valid new governor datum/governor validator should pass,103054094,227264,7467
|
||||
Benchmark/Effects/Governor Mutation Effect/validator/valid new governor datum/effect validator should pass,126696096,263635,3293
|
||||
Benchmark/Stake/policy/stakeCreation,147898986,329450,2265
|
||||
Benchmark/Stake/validator/stakeDepositWithdraw deposit,261845190,576377,3829
|
||||
Benchmark/Stake/validator/stakeDepositWithdraw withdraw,261845190,576377,3821
|
||||
Benchmark/Proposal/policy/proposalCreation,34571405,70066,1549
|
||||
Benchmark/Proposal/validator/cosignature/proposal,242652509,511783,5247
|
||||
Benchmark/Proposal/validator/cosignature/stake,183513647,395070,4366
|
||||
Benchmark/Proposal/validator/voting/proposal,240358004,492704,5255
|
||||
Benchmark/Proposal/validator/voting/stake,154841851,329311,4419
|
||||
Benchmark/AuthorityToken/singleAuthorityTokenBurned/Correct simple,25177457,55883,806
|
||||
Benchmark/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,40266637,88241,900
|
||||
Benchmark/Treasury/Validator/Positive/Allows for effect changes,37343572,79744,1841
|
||||
Benchmark/AuthorityToken/singleAuthorityTokenBurned/Correct simple,25177457,55883,806
|
||||
Benchmark/AuthorityToken/singleAuthorityTokenBurned/Correct many inputs,40266637,88241,900
|
||||
Benchmark/Governor/policy/GST minting,57648280,119961,1836
|
||||
Benchmark/Governor/validator/proposal creation,309839049,649395,7994
|
||||
Benchmark/Governor/validator/GATs minting,429394828,928681,8113
|
||||
Benchmark/Governor/validator/mutate governor state,100243054,221538,7540
|
||||
|
|
|
|||
|
Loading…
Add table
Add a link
Reference in a new issue