Skip to content

Commit

Permalink
Modules beta
Browse files Browse the repository at this point in the history
  • Loading branch information
fmaste committed Jul 6, 2024
1 parent 8f749de commit 9566078
Show file tree
Hide file tree
Showing 20 changed files with 2,744 additions and 2,183 deletions.
74 changes: 36 additions & 38 deletions bench/cardano-profile/app/cardano-profile.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

import Prelude
import System.Environment (lookupEnv)
-- Package: aeson.
import qualified Data.Aeson as Aeson
-- Package: bytestring.
import qualified Data.ByteString.Lazy.Char8 as BSL8
-- Package: optparse-applicative-fork.
import qualified Options.Applicative as OA

import qualified Cardano.Benchmarking.Profile as Profile
import qualified Cardano.Benchmarking.Profile.Map as Map
-- Package: self.
import qualified Cardano.Benchmarking.Profile as Profiles
import qualified Cardano.Benchmarking.Profile.Types as Types

--------------------------------------------------------------------------------

Expand All @@ -29,18 +32,18 @@ main = do
)
case cli of
-- Print all profile names.
Names -> BSL8.putStrLn $ Aeson.encode $ Map.names
Names -> BSL8.putStrLn $ Aeson.encode Profiles.names
-- Print a map with all profiles, with an optional overlay.
All -> do
obj <- lookupOverlay
BSL8.putStrLn $ Aeson.encode $ Map.profiles obj
BSL8.putStrLn $ Aeson.encode $ Profiles.profiles obj
-- Print a single profiles, with an optional overlay.
(Make profileName) -> do
obj <- lookupOverlay
case Map.byName profileName obj of
case Profiles.byName profileName obj of
Nothing -> error $ "No profile named \"" ++ profileName ++ "\""
(Just profile) ->
let aeson = Aeson.encode $ profile
let aeson = Aeson.encode profile
in BSL8.putStrLn aeson
(ToJson filePath) -> print filePath
-- str <- readFile filePath
Expand All @@ -51,7 +54,7 @@ main = do
eitherProfile <- Aeson.eitherDecodeFileStrict filePath
case eitherProfile of
(Left errorMsg) -> fail errorMsg
(Right profile) -> putStrLn $ show (profile :: Profile.Profile)
(Right profile) -> print (profile :: Types.Profile)

lookupOverlay :: IO Aeson.Object
lookupOverlay = do
Expand All @@ -66,40 +69,35 @@ lookupOverlay = do

cliParser :: OA.Parser Cli
cliParser = OA.hsubparser $
(OA.command "names"
(OA.info
(pure Names)
(OA.fullDesc <> OA.header "names" <> OA.progDesc "All profiles names")
)
)
OA.command "names"
(OA.info
(pure Names)
(OA.fullDesc <> OA.header "names" <> OA.progDesc "All profiles names")
)
<>
(OA.command "all"
(OA.info
(pure All)
(OA.fullDesc <> OA.header "all" <> OA.progDesc "All profiles")
)
)
OA.command "all"
(OA.info
(pure All)
(OA.fullDesc <> OA.header "all" <> OA.progDesc "All profiles")
)
<>
(OA.command "make"
(OA.info
(Make <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
(OA.fullDesc <> OA.header "make" <> OA.progDesc "Create profile")
)
)
OA.command "make"
(OA.info
(Make <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
(OA.fullDesc <> OA.header "make" <> OA.progDesc "Create profile")
)
<>
(OA.command "to-json"
(OA.info
(ToJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "to-json" <> OA.progDesc "Data type to JSON")
)
)
OA.command "to-json"
(OA.info
(ToJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "to-json" <> OA.progDesc "Data type to JSON")
)
<>
(OA.command "from-json"
(OA.info
(FromJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "from-json" <> OA.progDesc "JSON to data type")
)
)
OA.command "from-json"
(OA.info
(FromJson <$> OA.argument OA.str (OA.metavar "FILE"))
(OA.fullDesc <> OA.header "from-json" <> OA.progDesc "JSON to data type")
)

--------------------------------------------------------------------------------

Expand Down
15 changes: 14 additions & 1 deletion bench/cardano-profile/cardano-profile.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ library
other-modules: Paths_cardano_profile
autogen-modules: Paths_cardano_profile
exposed-modules: Cardano.Benchmarking.Profile
, Cardano.Benchmarking.Profile.Map
, Cardano.Benchmarking.Profile.Builtin.AdHoc.Dense
, Cardano.Benchmarking.Profile.Builtin.AdHoc.Dish
, Cardano.Benchmarking.Profile.Builtin.Cloud
, Cardano.Benchmarking.Profile.Builtin.Empty
, Cardano.Benchmarking.Profile.Builtin.ForgeStress
, Cardano.Benchmarking.Profile.Builtin.Plutuscall
, Cardano.Benchmarking.Profile.Builtin.Scenario.Base
, Cardano.Benchmarking.Profile.Builtin.Scenario.Chainsync
, Cardano.Benchmarking.Profile.Builtin.Scenario.Latency
, Cardano.Benchmarking.Profile.Builtin.Scenario.Idle
, Cardano.Benchmarking.Profile.Builtin.Scenario.TracerOnly
, Cardano.Benchmarking.Profile.Extra.Scaling
, Cardano.Benchmarking.Profile.Primitives
, Cardano.Benchmarking.Profile.Vocabulary
, Cardano.Benchmarking.Profile.Types
build-depends: base >=4.12 && <5
, time
Expand Down
Loading

0 comments on commit 9566078

Please sign in to comment.