Skip to content

Commit 4cdcd50

Browse files
committed
cardano-profile: new profiles forge-stress-pre-large, plutusv3-ripemd cloud; maintenance
1 parent d0dcd9b commit 4cdcd50

File tree

16 files changed

+18829
-7748
lines changed

16 files changed

+18829
-7748
lines changed

bench/cardano-profile/app/cardano-profile.hs

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import Prelude
66

7-
import Data.Function ((&))
7+
import Data.Bool (bool)
88
import System.Environment (lookupEnv)
99
import GHC.Stack (HasCallStack)
1010
-- Package: aeson.
@@ -79,17 +79,19 @@ data Cli =
7979
NamesNoEra
8080
| NamesCloudNoEra
8181
| Names
82-
| All
83-
| ByName PrettyPrint String
82+
| All [CliOptions]
83+
| ByName [CliOptions] String
8484
| LibMK
8585
| NodeSpecs FilePath FilePath
8686
| EpochTimeline Integer
8787
| ToJson String
8888
| FromJson String
8989

90-
data PrettyPrint =
91-
PrettyPrint
92-
| SingleLine
90+
data CliOptions =
91+
OptPrettyPrint
92+
| OptWithEra
93+
| OptWithPlayground
94+
deriving Eq
9395

9496
--------------------------------------------------------------------------------
9597

@@ -106,31 +108,19 @@ toMap maybeObj ps = Map.fromList $ map
106108
)
107109
ps
108110

109-
-- All profiles are created/defined in the Conway era.
110-
addEras :: Map.Map String Types.Profile -> Map.Map String Types.Profile
111-
addEras = foldMap
112-
(\profile -> Map.fromList $
113-
let
114-
-- TODO: Profiles properties other than the "name" and "era" of
115-
-- type string are the only thing that change ??? Remove the
116-
-- concept of eras from the profile definitions and make it a
117-
-- workbench-level feature (???).
118-
addEra p era suffix =
119-
let name = Types.name p
120-
newName = name ++ "-" ++ suffix
121-
in (newName, p {Types.name = newName, Types.era = era})
122-
in
123-
[ addEra profile Types.Allegra "alra"
124-
, addEra profile Types.Shelley "shey"
125-
, addEra profile Types.Mary "mary"
126-
, addEra profile Types.Alonzo "alzo"
127-
, addEra profile Types.Babbage "bage"
128-
, addEra profile Types.Conway "coay"
129-
]
130-
)
131-
132111
--------------------------------------------------------------------------------
133112

113+
encoder :: Aeson.ToJSON a => [CliOptions] -> a -> BSL8.ByteString
114+
encoder opts
115+
| OptPrettyPrint `elem` opts = Aeson.encodePretty' prettyConf
116+
| otherwise = Aeson.encode
117+
where
118+
prettyConf = defConfig
119+
{ confCompare = compare
120+
, confTrailingNewline = True
121+
, confIndent = Spaces 2
122+
}
123+
134124
main :: IO ()
135125
main = do
136126
cli <- getOpts
@@ -142,24 +132,24 @@ main = do
142132
-- Print all profile names (applies overlays!!!!!).
143133
Names -> do
144134
maybeObj <- lookupOverlay -- Ignored by `NamesNoEra` and `NamesCloudNoEra`.
145-
BSL8.putStrLn $ Aeson.encode $ Map.keys $ addEras $ toMap maybeObj allProfiles
135+
BSL8.putStrLn $ Aeson.encode $ Map.keys $ Profile.addEras $ toMap maybeObj allProfiles
146136
-- Print a map with all profiles, with an optional overlay.
147-
All -> do
137+
All cliOptions -> do
138+
let
139+
targetProfiles = if OptWithPlayground `elem` cliOptions then allProfiles else performanceAndTracingProfiles
140+
enc = encoder cliOptions
141+
withEraSuffs = OptWithEra `elem` cliOptions
148142
maybeObj <- lookupOverlay -- Ignored by `NamesNoEra` and `NamesCloudNoEra`.
149-
BSL8.putStrLn $ Aeson.encode $ addEras $ toMap maybeObj allProfiles
143+
BSL8.putStrLn $ enc $ bool id Profile.addEras withEraSuffs $ toMap maybeObj targetProfiles
150144
-- Print a single profiles, with an optional overlay.
151-
(ByName prettyPrint profileName) -> do
145+
ByName cliOptions profileName -> do
152146
maybeObj <- lookupOverlay -- Ignored by `NamesNoEra` and `NamesCloudNoEra`.
153-
let profiles = addEras $ toMap maybeObj allProfiles
147+
let
148+
enc = encoder cliOptions
149+
profiles = Profile.addEras $ toMap maybeObj allProfiles
154150
case Map.lookup profileName profiles of
155-
Nothing -> error $ "No profile named \"" ++ profileName ++ "\""
156-
(Just profile) ->
157-
let
158-
prettyConf = defConfig { confCompare = compare, confTrailingNewline = True }
159-
aeson = profile & case prettyPrint of
160-
PrettyPrint -> Aeson.encodePretty' prettyConf
161-
SingleLine -> Aeson.encode
162-
in BSL8.putStrLn aeson
151+
Nothing -> error $ "No profile named \"" ++ profileName ++ "\""
152+
Just profile -> BSL8.putStrLn $ enc profile
163153
LibMK -> do
164154
mapM_ putStrLn libMk
165155
(NodeSpecs profilePath topologyPath) -> do
@@ -229,19 +219,31 @@ cliParser = OA.hsubparser $
229219
<>
230220
OA.command "all"
231221
(OA.info
232-
(pure All)
222+
(pure $ All [OptWithEra, OptWithPlayground])
233223
(OA.fullDesc <> OA.header "all" <> OA.progDesc "Create all profiles")
234224
)
225+
<>
226+
OA.command "all-noera"
227+
(OA.info
228+
(pure $ All [OptWithPlayground])
229+
(OA.fullDesc <> OA.header "all-noera" <> OA.progDesc "Create all profiles (no era suffix)")
230+
)
231+
<>
232+
OA.command "allpt-noera"
233+
(OA.info
234+
(pure $ All [OptPrettyPrint])
235+
(OA.fullDesc <> OA.header "allpt-noera" <> OA.progDesc "Create P&T profiles (no era suffix)")
236+
)
235237
<>
236238
OA.command "by-name"
237239
(OA.info
238-
(ByName SingleLine <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
240+
(ByName [] <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
239241
(OA.fullDesc <> OA.header "by-name" <> OA.progDesc "Create profile")
240242
)
241243
<>
242244
OA.command "by-name-pretty"
243245
(OA.info
244-
(ByName PrettyPrint <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
246+
(ByName [OptPrettyPrint] <$> OA.argument OA.str (OA.metavar "PROFILE-NAME"))
245247
(OA.fullDesc <> OA.header "by-name-pretty" <> OA.progDesc "Create profile (pretty-printed)")
246248
)
247249
<>

bench/cardano-profile/cardano-profile.cabal

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cabal-version: 3.0
22

33
name: cardano-profile
4-
version: 8.7.0
4+
version: 8.8.0
55
synopsis: A Cardano benchmarking profile generator
66
description: A Cardano benchmarking profile generator.
77
category: Cardano,
@@ -32,7 +32,8 @@ data-files: data/all-profiles-coay.json
3232
common project-config
3333
build-depends: base >= 4.14 && < 5
3434
default-language: Haskell2010
35-
default-extensions: NoImplicitPrelude
35+
default-extensions: LambdaCase
36+
NoImplicitPrelude
3637
ghc-options: -Wall
3738
-Wcompat
3839
-Wincomplete-record-updates
@@ -107,6 +108,8 @@ executable cardano-timeline
107108

108109
test-suite cardano-profile-test
109110
import: project-config
111+
-- GHC9.12's warning turns to an error in CI
112+
ghc-options: -Wno-unused-imports
110113
hs-source-dirs: test/
111114
main-is: Main.hs
112115
type: exitcode-stdio-1.0

0 commit comments

Comments
 (0)