Skip to content

Commit deb508b

Browse files
author
github-actions
committed
Format with fourmolu
1 parent cb3ae44 commit deb508b

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

dev-tools/process-logs/Main.hs

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ import System.Exit
2828
import Text.Printf
2929

3030
import Booster.Log.Context (ContextFilter, mustMatch, readContextFilter)
31-
import Kore.JsonRpc.Types.ContextLog
3231
import Kore.JsonRpc.Types (rpcJsonConfig)
32+
import Kore.JsonRpc.Types.ContextLog
3333

3434
-- reads log file in json-format from stdin (or a single given file)
3535
-- applies the command
@@ -59,10 +59,10 @@ data Options = Options
5959
data Command
6060
= -- | filter a log file, output to stdout. Same options as for the server
6161
Filter [ContextFilter]
62-
-- | find repeated rule/equation contexts in lines
63-
| FindRecursions
64-
-- | compute total times spent on applying certain rules/equations (top-level)
65-
| TimesPerRule
62+
| -- | find repeated rule/equation contexts in lines
63+
FindRecursions
64+
| -- | compute total times spent on applying certain rules/equations (top-level)
65+
TimesPerRule
6666
deriving (Show)
6767

6868
parse :: ParserInfo Options
@@ -157,7 +157,6 @@ process TimesPerRule =
157157
stats.tAbort
158158
stats.nAbort
159159

160-
161160
encodeLogLine :: LogLine -> BS.ByteString
162161
encodeLogLine = JSON.encodePretty' rpcJsonConfig{JSON.confIndent = JSON.Spaces 0}
163162

@@ -227,17 +226,16 @@ ruleStatistics =
227226
allTimes :: RuleStats -> Double
228227
allTimes stats = stats.tSuccess + stats.tFailure + stats.tAbort
229228

230-
data RuleStats =
231-
RuleStats
232-
{ -- counts of:
233-
nSuccess :: !Int -- successful application
234-
, nFailure :: !Int -- failure to apply
235-
, nAbort :: !Int -- failure, leading to abort
236-
, -- total times for these categories
237-
tSuccess :: !Double
238-
, tFailure :: !Double
239-
, tAbort :: !Double
240-
}
229+
data RuleStats = RuleStats
230+
{ -- counts of:
231+
nSuccess :: !Int -- successful application
232+
, nFailure :: !Int -- failure to apply
233+
, nAbort :: !Int -- failure, leading to abort
234+
, -- total times for these categories
235+
tSuccess :: !Double
236+
, tFailure :: !Double
237+
, tAbort :: !Double
238+
}
241239
deriving stock (Eq, Ord, Show)
242240

243241
instance Monoid RuleStats where
@@ -259,7 +257,8 @@ ruleStats = Map.fromListWith (<>) . collect
259257
where
260258
collect [] = []
261259
collect (l@LogLine{context} : ls)
262-
| Seq.null rulePart = -- no rule involved?
260+
| Seq.null rulePart -- no rule involved?
261+
=
263262
collect ls
264263
| otherwise =
265264
let (outcome, rest) = fromCtxSpan (prefix :|> ruleCtx) (l : ls)
@@ -269,7 +268,7 @@ ruleStats = Map.fromListWith (<>) . collect
269268
(ruleCtx, ruleId) = case rulePart of
270269
hd :<| _rest
271270
| c@(CLWithId c') <- hd -> (c, c')
272-
| CLNullary{} <- hd -> error "no rule head found"
271+
| CLNullary{} <- hd -> error "no rule head found"
273272
Seq.Empty -> error "no rule head found"
274273

275274
-- only contexts with ID (rules, equations, hooks)
@@ -295,16 +294,17 @@ ruleStats = Map.fromListWith (<>) . collect
295294
mkOutcome startLine endLine =
296295
let time =
297296
maybe 1 realToFrac $
298-
(diffUTCTime
297+
( diffUTCTime
299298
<$> fmap systemToUTCTime endLine.timestamp
300299
<*> fmap systemToUTCTime startLine.timestamp
301300
)
302301
in case endLine.context of
303-
_ :|> CLNullary CtxSuccess ->
304-
RuleStats 1 0 0 time 0 0
305-
_ :|> CLNullary CtxFailure ->
306-
RuleStats 0 1 0 0 time 0
307-
_ :|> CLNullary CtxAbort ->
308-
RuleStats 0 0 1 0 0 time
309-
other -> -- case not covered...
310-
error $ "Unexpected last context " <> show (Seq.drop len other)
302+
_ :|> CLNullary CtxSuccess ->
303+
RuleStats 1 0 0 time 0 0
304+
_ :|> CLNullary CtxFailure ->
305+
RuleStats 0 1 0 0 time 0
306+
_ :|> CLNullary CtxAbort ->
307+
RuleStats 0 0 1 0 0 time
308+
other ->
309+
-- case not covered...
310+
error $ "Unexpected last context " <> show (Seq.drop len other)

0 commit comments

Comments
 (0)