Skip to content

Commit 9110079

Browse files
committed
locli: Summary analysis; tons more metrics; better reports; cleanups
1 parent 5d8f0dd commit 9110079

25 files changed

+1063
-653
lines changed

bench/locli/locli.cabal

+1
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ library
107107
, extra
108108
, file-embed
109109
, filepath
110+
, fingertree
110111
, ghc
111112
, gnuplot
112113
, iohk-monitoring

bench/locli/src/Cardano/Analysis/API.hs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
module Cardano.Analysis.API
2-
( module Cardano.Analysis.API.Chain
2+
( module Data.CDF
3+
, module Cardano.Analysis.API.Chain
34
, module Cardano.Analysis.API.ChainFilter
45
, module Cardano.Analysis.API.Context
56
, module Cardano.Analysis.API.Dictionary
@@ -12,6 +13,7 @@ module Cardano.Analysis.API
1213
)
1314
where
1415

16+
import Data.CDF
1517
import Cardano.Analysis.API.Chain
1618
import Cardano.Analysis.API.ChainFilter
1719
import Cardano.Analysis.API.Context

bench/locli/src/Cardano/Analysis/API/Field.hs

+45-9
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import Data.Text (unpack)
1111
import Cardano.JSON
1212
import Cardano.Util
1313
import Cardano.Analysis.API.Ground
14-
import Cardano.Analysis.API.Run
1514

1615

1716
data Scale
@@ -23,6 +22,7 @@ data Range
2322
= Free -- No range restriction
2423
| Z0 Int -- 1-based range
2524
| Z1 Int -- 1-based range
25+
| R01
2626
deriving (Eq, Show)
2727

2828
data Unit
@@ -33,6 +33,7 @@ data Unit
3333
| MB -- Mibibyte: 2^20
3434
| KBs -- Kibibyte/s
3535
| MBs -- Mibibyte/s
36+
| Era -- Era
3637
| Epo -- Epoch
3738
| Slo -- Slots
3839
| Blk -- Blocks
@@ -41,10 +42,16 @@ data Unit
4142
| Sig -- Sign: +/-
4243
| Pct -- Unspecified ratio, percents
4344
| Ev -- Events
45+
| KEv -- Events: 10^3
46+
| Dat -- Date
47+
| Tim -- Time
48+
| Ver -- Version
4449
| Ix -- Unspecified index
4550
| Len -- Unspecified length
51+
| Cnt -- Unspecified count
4652
| Rto -- Unspecified ratio
4753
| Uni -- Unspecified unit
54+
| Id -- Unspefified identifier
4855
deriving (Eq, Show)
4956

5057
renderUnit :: Unit -> Text
@@ -56,21 +63,28 @@ renderUnit = \case
5663
MB -> "MB"
5764
KBs -> "KB/s"
5865
MBs -> "MB/s"
66+
Era -> "era"
5967
Epo -> "epoch"
6068
Slo -> "slots"
6169
Blk -> "blocks"
6270
Hsh -> "hash"
6371
Hos -> "host"
6472
Sig -> "+/-"
6573
Pct -> "%"
66-
Ev -> ""
67-
Ix -> ""
68-
Len -> ""
69-
Rto -> ""
70-
Uni -> ""
74+
Ev -> "#"
75+
KEv -> "#"
76+
Dat -> "on"
77+
Tim -> "at"
78+
Ver -> "v"
79+
Ix -> "[]"
80+
Len -> "#"
81+
Cnt -> "#"
82+
Rto -> "/"
83+
Uni -> "#"
84+
Id -> ""
7185

7286
data Width
73-
= W0
87+
= Wno
7488
| W1
7589
| W2
7690
| W3
@@ -83,6 +97,15 @@ data Width
8397
| W10
8498
| W11
8599
| W12
100+
| W13
101+
| W14
102+
| W15
103+
| W16
104+
| W17
105+
| W18
106+
| W19
107+
| W20
108+
| W21
86109
deriving (Eq, Enum, Ord, Show)
87110

88111
data Precision
@@ -94,7 +117,8 @@ data Precision
94117

95118
{-# INLINE width #-}
96119
width :: Width -> Int
97-
width = fromEnum
120+
width Wno = 80
121+
width x = fromEnum x
98122

99123
-- | Encapsulate all metadata about a metric (a projection) of
100124
-- a certain projectible (a kind of analysis results):
@@ -122,10 +146,14 @@ class CDFFields a p where
122146

123147
class TimelineFields a where
124148
data TimelineComments a :: Type
125-
timelineFields :: Run -> [Field ISelect I a]
149+
timelineFields :: [Field ISelect I a]
126150
rtCommentary :: a -> TimelineComments a -> [Text]
127151
rtCommentary _ _ = []
128152

153+
data FSelect where
154+
ISel :: TimelineFields a => (Field ISelect I a -> Bool) -> FSelect
155+
DSel :: CDFFields a p => (Field DSelect p a -> Bool) -> FSelect
156+
129157
data DSelect p a
130158
= DInt (a p -> CDF p Int)
131159
| DWord64 (a p -> CDF p Word64)
@@ -139,8 +167,16 @@ data ISelect p a
139167
| IFloat (a -> Double)
140168
| IDeltaT (a -> NominalDiffTime)
141169
| IDeltaTM (a -> SMaybe NominalDiffTime)
170+
| IDate (a -> UTCTime)
171+
| ITime (a -> UTCTime)
142172
| IText (a -> Text)
143173

174+
dFields :: [FieldName] -> Field DSelect p a -> Bool
175+
dFields fs Field{fId} = FieldName fId `elem` fs
176+
177+
iFields :: [FieldName] -> Field ISelect I a -> Bool
178+
iFields fs Field{fId} = FieldName fId `elem` fs
179+
144180
filterFields :: CDFFields a p
145181
=> (Field DSelect p a -> Bool) -> [Field DSelect p a]
146182
filterFields f = filter f cdfFields

bench/locli/src/Cardano/Analysis/API/Ground.hs

+16-4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ import Data.DataDomain
3434
import Cardano.Util
3535

3636

37+
newtype FieldName = FieldName { unFieldName :: Text }
38+
deriving (Eq, Generic, Ord)
39+
deriving newtype (FromJSON, IsString, ToJSON)
40+
deriving anyclass NFData
41+
deriving Show via Quiet FieldName
42+
3743
newtype TId = TId { unTId :: ShortText }
3844
deriving (Eq, Generic, Ord)
3945
deriving newtype (FromJSON, ToJSON)
@@ -60,11 +66,17 @@ newtype Count a = Count { unCount :: Int }
6066
deriving newtype (FromJSON, Num, ToJSON)
6167
deriving anyclass NFData
6268

63-
countOfList :: [a] -> Count a
64-
countOfList = Count . fromIntegral . length
69+
countList :: (a -> Bool) -> [a] -> Count a
70+
countList f = Count . fromIntegral . count f
71+
72+
countLists :: (a -> Bool) -> [[a]] -> Count a
73+
countLists f = Count . fromIntegral . sum . fmap (count f)
74+
75+
countListAll :: [a] -> Count a
76+
countListAll = Count . fromIntegral . length
6577

66-
countOfLists :: [[a]] -> Count a
67-
countOfLists = Count . fromIntegral . sum . fmap length
78+
countListsAll :: [[a]] -> Count a
79+
countListsAll = Count . fromIntegral . sum . fmap length
6880

6981
unsafeCoerceCount :: Count a -> Count b
7082
unsafeCoerceCount = Unsafe.unsafeCoerce

0 commit comments

Comments
 (0)