CSV would be better than JSON
This commit is contained in:
parent
35ba59c5d6
commit
29dc10bf36
4 changed files with 41 additions and 22 deletions
|
|
@ -1,12 +1,15 @@
|
||||||
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
|
||||||
module Bench (Benchmark (..), benchmarkScript, specificationTreeToBenchmarks) where
|
module Bench (Benchmark (..), benchmarkScript, specificationTreeToBenchmarks) where
|
||||||
|
|
||||||
import Codec.Serialise (serialise)
|
import Codec.Serialise (serialise)
|
||||||
import Data.Aeson hiding (Success)
|
|
||||||
import Data.ByteString.Lazy qualified as LBS
|
import Data.ByteString.Lazy qualified as LBS
|
||||||
import Data.ByteString.Short qualified as SBS
|
import Data.ByteString.Short qualified as SBS
|
||||||
|
import Data.Csv (ToNamedRecord, DefaultOrdered, toNamedRecord, namedRecord, header, headerOrder, (.=))
|
||||||
import Data.List (intercalate)
|
import Data.List (intercalate)
|
||||||
import Data.Maybe (fromJust)
|
import Data.Maybe (fromJust)
|
||||||
import Data.Text (Text, pack)
|
import Data.Text (Text, pack)
|
||||||
|
import GHC.Generics (Generic)
|
||||||
import Plutus.V1.Ledger.Api (
|
import Plutus.V1.Ledger.Api (
|
||||||
ExBudget (ExBudget),
|
ExBudget (ExBudget),
|
||||||
ExCPU,
|
ExCPU,
|
||||||
|
|
@ -34,25 +37,20 @@ data Benchmark = Benchmark
|
||||||
, bScriptSize :: Int
|
, bScriptSize :: Int
|
||||||
-- ^ The on-chain size of a script.
|
-- ^ The on-chain size of a script.
|
||||||
}
|
}
|
||||||
deriving stock (Show, Eq, Ord)
|
deriving stock (Show, Eq, Ord, Generic)
|
||||||
|
|
||||||
instance FromJSON Benchmark where
|
instance ToNamedRecord Benchmark where
|
||||||
parseJSON (Object v) =
|
toNamedRecord (Benchmark {..}) =
|
||||||
Benchmark <$> v .: "name"
|
namedRecord
|
||||||
<*> v .: "cpu"
|
|
||||||
<*> v .: "mem"
|
|
||||||
<*> v .: "size"
|
|
||||||
parseJSON _ = mempty
|
|
||||||
|
|
||||||
instance ToJSON Benchmark where
|
|
||||||
toJSON (Benchmark name cpu mem size) =
|
|
||||||
object
|
|
||||||
[ "name" .= name
|
[ "name" .= name
|
||||||
, "cpu" .= cpu
|
, "cpu" .= bCPUBudget
|
||||||
, "mem" .= mem
|
, "mem" .= bMemoryBudget
|
||||||
, "size" .= size
|
, "size" .= bScriptSize
|
||||||
]
|
]
|
||||||
|
|
||||||
|
instance DefaultOrdered Benchmark where
|
||||||
|
headerOrder _ = header ["name", "cpu", "mem", "size"]
|
||||||
|
|
||||||
benchmarkScript :: String -> Script -> Benchmark
|
benchmarkScript :: String -> Script -> Benchmark
|
||||||
benchmarkScript name script = Benchmark (pack name) cpu mem size
|
benchmarkScript name script = Benchmark (pack name) cpu mem size
|
||||||
where
|
where
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
module Main (main) where
|
module Main (main) where
|
||||||
|
|
||||||
import Bench (specificationTreeToBenchmarks)
|
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 Data.Text.Lazy.IO as I
|
||||||
import Spec.AuthorityToken qualified as AuthorityToken
|
import Spec.AuthorityToken qualified as AuthorityToken
|
||||||
import Spec.Effect.GovernorMutation qualified as GovernorMutation
|
import Spec.Effect.GovernorMutation qualified as GovernorMutation
|
||||||
|
|
@ -17,8 +18,8 @@ import Prelude
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
I.writeFile "bench.json" $
|
I.writeFile "bench.csv" $
|
||||||
encodeToLazyText $
|
(decodeUtf8 . encodeDefaultOrderedByName) $
|
||||||
specificationTreeToBenchmarks $
|
specificationTreeToBenchmarks $
|
||||||
group
|
group
|
||||||
"Benchmark"
|
"Benchmark"
|
||||||
|
|
|
||||||
|
|
@ -218,6 +218,7 @@ benchmark agora-bench
|
||||||
, agora
|
, agora
|
||||||
, agora-sample
|
, agora-sample
|
||||||
, agora-spec
|
, agora-spec
|
||||||
|
, cassava
|
||||||
|
|
||||||
executable agora-scripts
|
executable agora-scripts
|
||||||
import: lang, deps, exe-opts
|
import: lang, deps, exe-opts
|
||||||
|
|
|
||||||
25
bench.csv
25
bench.csv
|
|
@ -1,4 +1,23 @@
|
||||||
name,cpu,mem,size
|
name,cpu,mem,size
|
||||||
full_scripts:authorityTokenPolicy,1756707,6000,841
|
Benchmark/Effects/Treasury Withdrawal Effect/effect/Simple,340268715,724428,3050
|
||||||
full_scripts:stakePolicy,3751498,12700,1610
|
Benchmark/Effects/Treasury Withdrawal Effect/effect/Simple with multiple treasuries ,570029812,1211300,3377
|
||||||
full_scripts:stakeValidator,3126265,10600,1500
|
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