Skip to content

Commit 64e5e85

Browse files
committed
formatting
1 parent 145355e commit 64e5e85

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

dev-tools/process-logs/Main.hs

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import Data.List (foldl', maximumBy, sortBy)
1818
import Data.Map (Map)
1919
import Data.Map qualified as Map
2020
import Data.Maybe (mapMaybe)
21-
import Data.Ord (comparing, Down (..))
21+
import Data.Ord (Down (..), comparing)
2222
import Data.Sequence (Seq (..))
2323
import Data.Sequence qualified as Seq
2424
import Data.Time.Clock
@@ -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
@@ -148,7 +148,7 @@ process TimesPerRule =
148148
renderResult (ctx, stats) =
149149
BS.pack $
150150
printf
151-
"| %22s | %10.6fs (%5d) | %10.6fs (%5d) | %10.6fs (%5d)"
151+
"| %22s | %10.6fs (%5d) | %10.6fs (%5d) | %10.6fs (%5d)"
152152
(show ctx)
153153
stats.tSuccess
154154
stats.nSuccess
@@ -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)
@@ -296,22 +295,23 @@ ruleStats = Map.fromListWith (<>) . collect
296295
maybe
297296
1
298297
realToFrac
299-
(diffUTCTime
298+
( diffUTCTime
300299
<$> fmap systemToUTCTime endLine.timestamp
301300
<*> fmap systemToUTCTime startLine.timestamp
302301
)
303302
in case Seq.drop len endLine.context of
304-
CLNullary CtxSuccess :<| _ ->
305-
RuleStats 1 0 0 time 0 0
303+
CLNullary CtxSuccess :<| _ ->
304+
RuleStats 1 0 0 time 0 0
306305
-- rewrite failures
307-
_ :|> CLNullary CtxFailure ->
308-
RuleStats 0 1 0 0 time 0
309-
_ :|> CLNullary CtxIndeterminate ->
310-
RuleStats 0 0 1 0 0 time
306+
_ :|> CLNullary CtxFailure ->
307+
RuleStats 0 1 0 0 time 0
308+
_ :|> CLNullary CtxIndeterminate ->
309+
RuleStats 0 0 1 0 0 time
311310
-- equation failures
312-
_ :|> CLNullary CtxContinue ->
313-
RuleStats 0 1 0 0 time 0
314-
_ :|> CLNullary CtxBreak ->
315-
RuleStats 0 0 1 0 0 time
316-
other -> -- case not covered...
317-
error $ "Unexpected last context " <> show other
311+
_ :|> CLNullary CtxContinue ->
312+
RuleStats 0 1 0 0 time 0
313+
_ :|> CLNullary CtxBreak ->
314+
RuleStats 0 0 1 0 0 time
315+
other ->
316+
-- case not covered...
317+
error $ "Unexpected last context " <> show other

0 commit comments

Comments
 (0)