Skip to content

Commit

Permalink
locli: discern RIPEMD-160 in reports; cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmeier committed Nov 19, 2024
1 parent 3ffcb0f commit fc3ee5e
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 47 deletions.
8 changes: 8 additions & 0 deletions bench/locli/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Revision history for locli

## 1.36 -- Nov 2024

* Add `CHANGELOG.md` for `locli`
* Discern Plutus RIPEMD-160 workload in reports
* Remove unused build-depends

25 changes: 5 additions & 20 deletions bench/locli/locli.cabal
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
cabal-version: 3.0

name: locli
version: 1.35
version: 1.36
synopsis: Cardano log analysis CLI
description: Cardano log analysis CLI.
category: Cardano,
Expand All @@ -12,6 +12,7 @@ maintainer: [email protected]
license: Apache-2.0
license-files: LICENSE
NOTICE
extra-doc-files: CHANGELOG.md
build-type: Simple

common project-config
Expand Down Expand Up @@ -95,11 +96,8 @@ library
autogen-modules: Paths_locli

build-depends: aeson
, Histogram
, aeson-pretty
, async
, attoparsec
, attoparsec-iso8601
, bytestring
, cardano-git-rev ^>= 0.2.2
, cardano-ledger-core
Expand All @@ -110,27 +108,17 @@ library
, directory
, ede
, extra
, file-embed
, filepath
, fingertree
, hashable
, gnuplot
, iohk-monitoring
, optparse-applicative-fork
, optparse-generic
-- , gnuplot
, optparse-applicative-fork >= 0.18.1
, ouroboros-consensus
-- for Data.SOP.Strict:
, ouroboros-network ^>= 0.17
, ouroboros-network-api
, process
, quiet
, scientific
, ouroboros-network-api ^>= 0.10
, sop-core
, split
, statistics
, strict-sop-core
, system-filepath
, template-haskell
, text
, text-short
, time
Expand All @@ -139,18 +127,15 @@ library
, transformers-except
, unix
, unordered-containers
, utf8-string
, vector
, witherable
, cardano-strict-containers ^>= 0.1

executable locli
import: project-config

hs-source-dirs: app
main-is: locli.hs
ghc-options: -threaded
-Wall
-rtsopts
"-with-rtsopts=-T -N7 -A2m -qb -H64m"

Expand Down
37 changes: 10 additions & 27 deletions bench/locli/src/Cardano/Analysis/API/Ground.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ module Cardano.Analysis.API.Ground
)
where

import Prelude (show)
import Prelude as P (show)
import Cardano.Prelude hiding (head, toText)
import Unsafe.Coerce qualified as Unsafe

import Data.Aeson
import Data.Aeson.Types (toJSONKeyText)
import Data.Attoparsec.Text qualified as Atto
import Data.Attoparsec.Time qualified as Iso8601
import Data.ByteString.Lazy.Char8 qualified as LBS
import Data.Map.Strict qualified as Map
import Data.Text qualified as T
Expand All @@ -26,7 +24,6 @@ import Data.Text.Short (ShortText, fromText, toText)
import Data.Time.Clock (UTCTime, NominalDiffTime)
import Options.Applicative
import Options.Applicative qualified as Opt
import Quiet (Quiet (..))
import System.FilePath qualified as F

import Cardano.Slotting.Slot (EpochNo(..), SlotNo(..))
Expand All @@ -41,13 +38,17 @@ newtype FieldName = FieldName { unFieldName :: Text }
deriving (Eq, Generic, Ord)
deriving newtype (FromJSON, IsString, ToJSON)
deriving anyclass NFData
deriving Show via Quiet FieldName

instance Show FieldName where
show = ("FieldName " ++) . P.show . unFieldName

newtype TId = TId { unTId :: ShortText }
deriving (Eq, Generic, Ord)
deriving newtype (FromJSON, ToJSON)
deriving anyclass NFData
deriving Show via Quiet TId

instance Show TId where
show = ("TId " ++) . P.show . unTId

newtype Hash = Hash { unHash :: ShortText }
deriving (Eq, Generic, Ord)
Expand Down Expand Up @@ -95,7 +96,9 @@ newtype Host = Host { unHost :: ShortText }
deriving (Eq, Generic, Ord)
deriving newtype (IsString, FromJSON, ToJSON)
deriving anyclass NFData
deriving Show via Quiet Host

instance Show Host where
show = ("Host " ++) . P.show . unHost

newtype EpochSlot = EpochSlot { unEpochSlot :: Word64 }
deriving stock (Eq, Generic, Ord, Show)
Expand Down Expand Up @@ -269,26 +272,6 @@ pSlotNo name desc =
<> Opt.help desc
)

optUTCTime :: String -> String -> Parser UTCTime
optUTCTime optname desc =
Opt.option (readerFromAttoParser Iso8601.utcTime)
$ long optname
<> metavar "ISO8601-TIME"
<> help desc
where
-- Stolen from: cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs
readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a
readerFromAttoParser p =
Opt.eitherReader (Atto.parseOnly (p <* Atto.endOfInput) . T.pack)

optDuration :: String -> String -> NominalDiffTime -> Parser NominalDiffTime
optDuration optname desc def=
Opt.option ((realToFrac :: Double -> NominalDiffTime) <$> Opt.auto)
$ long optname
<> metavar "SEC"
<> help desc
<> value def

optWord :: String -> String -> Word64 -> Parser Word64
optWord optname desc def =
Opt.option auto
Expand Down
4 changes: 4 additions & 0 deletions bench/locli/src/Cardano/Report.hs
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ data Workload
| WPlutusLoopCountdown
| WPlutusLoopSECP
| WPlutusLoopBLST
| WPlutusLoopRipemd
| WPlutusUnknown

instance ToJSON Workload where
Expand All @@ -88,13 +89,15 @@ instance ToJSON Workload where
WPlutusLoopCountdown -> "Plutus countdown loop"
WPlutusLoopSECP -> "Plutus SECP loop"
WPlutusLoopBLST -> "Plutus BLST loop"
WPlutusLoopRipemd -> "Plutus RIPEMD-160 loop"
WPlutusUnknown -> "Plutus (other)"

filenameInfix :: Workload -> Text
filenameInfix = \case
WPlutusLoopCountdown -> "plutus"
WPlutusLoopSECP -> "plutus-secp"
WPlutusLoopBLST -> "plutus-blst"
WPlutusLoopRipemd -> "plutus-ripemd"
WValue -> "value-only"
_ -> "unknown"

Expand Down Expand Up @@ -150,6 +153,7 @@ liftTmplRun Summary{sumWorkload=generatorProfile
| script == "EcdsaSecp256k1Loop" -> WPlutusLoopSECP
| script == "SchnorrSecp256k1Loop" -> WPlutusLoopSECP
| script == "HashOntoG2AndAdd" -> WPlutusLoopBLST
| script == "Ripemd160" -> WPlutusLoopRipemd
| otherwise -> WPlutusUnknown
}

Expand Down

0 comments on commit fc3ee5e

Please sign in to comment.