export benchmark to json
This commit is contained in:
parent
5c438f0062
commit
ad957d6b02
4 changed files with 39 additions and 17 deletions
|
|
@ -1,6 +1,7 @@
|
|||
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.List (intercalate)
|
||||
|
|
@ -35,6 +36,23 @@ data Benchmark = Benchmark
|
|||
}
|
||||
deriving stock (Show, Eq, Ord)
|
||||
|
||||
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
|
||||
[ "name" .= name
|
||||
, "cpu" .= cpu
|
||||
, "mem" .= mem
|
||||
, "size" .= size
|
||||
]
|
||||
|
||||
benchmarkScript :: String -> Script -> Benchmark
|
||||
benchmarkScript name script = Benchmark (pack name) cpu mem size
|
||||
where
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
module Main (main) where
|
||||
|
||||
import Bench (specificationTreeToBenchmarks)
|
||||
import Data.Aeson.Text (encodeToLazyText)
|
||||
import Data.Text.Lazy.IO as I
|
||||
import Spec.AuthorityToken qualified as AuthorityToken
|
||||
import Spec.Effect.GovernorMutation qualified as GovernorMutation
|
||||
import Spec.Effect.TreasuryWithdrawal qualified as TreasuryWithdrawal
|
||||
|
|
@ -15,19 +17,20 @@ import Prelude
|
|||
|
||||
main :: IO ()
|
||||
main = do
|
||||
mapM_ print $
|
||||
specificationTreeToBenchmarks $
|
||||
group
|
||||
"Benchmark"
|
||||
[ group
|
||||
"Effects"
|
||||
[ group "Treasury Withdrawal Effect" TreasuryWithdrawal.specs
|
||||
, group "Governor Mutation Effect" GovernorMutation.specs
|
||||
]
|
||||
, group "Stake" Stake.specs
|
||||
, group "Proposal" Proposal.specs
|
||||
, group "AuthorityToken" AuthorityToken.specs
|
||||
, group "Treasury" Treasury.specs
|
||||
, group "AuthorityToken" AuthorityToken.specs
|
||||
, group "Governor" Governor.specs
|
||||
]
|
||||
I.writeFile "bench.json" $
|
||||
encodeToLazyText $
|
||||
specificationTreeToBenchmarks $
|
||||
group
|
||||
"Benchmark"
|
||||
[ group
|
||||
"Effects"
|
||||
[ group "Treasury Withdrawal Effect" TreasuryWithdrawal.specs
|
||||
, group "Governor Mutation Effect" GovernorMutation.specs
|
||||
]
|
||||
, group "Stake" Stake.specs
|
||||
, group "Proposal" Proposal.specs
|
||||
, group "AuthorityToken" AuthorityToken.specs
|
||||
, group "Treasury" Treasury.specs
|
||||
, group "AuthorityToken" AuthorityToken.specs
|
||||
, group "Governor" Governor.specs
|
||||
]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue