@@ -18,7 +18,7 @@ import Data.List (foldl', maximumBy, sortBy)
18
18
import Data.Map (Map )
19
19
import Data.Map qualified as Map
20
20
import Data.Maybe (mapMaybe )
21
- import Data.Ord (comparing , Down (.. ))
21
+ import Data.Ord (Down (.. ), comparing )
22
22
import Data.Sequence (Seq (.. ))
23
23
import Data.Sequence qualified as Seq
24
24
import Data.Time.Clock
@@ -28,8 +28,8 @@ import System.Exit
28
28
import Text.Printf
29
29
30
30
import Booster.Log.Context (ContextFilter , mustMatch , readContextFilter )
31
- import Kore.JsonRpc.Types.ContextLog
32
31
import Kore.JsonRpc.Types (rpcJsonConfig )
32
+ import Kore.JsonRpc.Types.ContextLog
33
33
34
34
-- reads log file in json-format from stdin (or a single given file)
35
35
-- applies the command
@@ -59,10 +59,10 @@ data Options = Options
59
59
data Command
60
60
= -- | filter a log file, output to stdout. Same options as for the server
61
61
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
66
66
deriving (Show )
67
67
68
68
parse :: ParserInfo Options
@@ -148,7 +148,7 @@ process TimesPerRule =
148
148
renderResult (ctx, stats) =
149
149
BS. pack $
150
150
printf
151
- " | %22s | %10.6fs (%5d) | %10.6fs (%5d) | %10.6fs (%5d)"
151
+ " | %22s | %10.6fs (%5d) | %10.6fs (%5d) | %10.6fs (%5d)"
152
152
(show ctx)
153
153
stats. tSuccess
154
154
stats. nSuccess
@@ -157,7 +157,6 @@ process TimesPerRule =
157
157
stats. tAbort
158
158
stats. nAbort
159
159
160
-
161
160
encodeLogLine :: LogLine -> BS. ByteString
162
161
encodeLogLine = JSON. encodePretty' rpcJsonConfig{JSON. confIndent = JSON. Spaces 0 }
163
162
@@ -227,17 +226,16 @@ ruleStatistics =
227
226
allTimes :: RuleStats -> Double
228
227
allTimes stats = stats. tSuccess + stats. tFailure + stats. tAbort
229
228
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
+ }
241
239
deriving stock (Eq , Ord , Show )
242
240
243
241
instance Monoid RuleStats where
@@ -259,7 +257,8 @@ ruleStats = Map.fromListWith (<>) . collect
259
257
where
260
258
collect [] = []
261
259
collect (l@ LogLine {context} : ls)
262
- | Seq. null rulePart = -- no rule involved?
260
+ | Seq. null rulePart -- no rule involved?
261
+ =
263
262
collect ls
264
263
| otherwise =
265
264
let (outcome, rest) = fromCtxSpan (prefix :|> ruleCtx) (l : ls)
@@ -269,7 +268,7 @@ ruleStats = Map.fromListWith (<>) . collect
269
268
(ruleCtx, ruleId) = case rulePart of
270
269
hd :<| _rest
271
270
| c@ (CLWithId c') <- hd -> (c, c')
272
- | CLNullary {} <- hd -> error " no rule head found"
271
+ | CLNullary {} <- hd -> error " no rule head found"
273
272
Seq. Empty -> error " no rule head found"
274
273
275
274
-- only contexts with ID (rules, equations, hooks)
@@ -296,22 +295,23 @@ ruleStats = Map.fromListWith (<>) . collect
296
295
maybe
297
296
1
298
297
realToFrac
299
- (diffUTCTime
298
+ ( diffUTCTime
300
299
<$> fmap systemToUTCTime endLine. timestamp
301
300
<*> fmap systemToUTCTime startLine. timestamp
302
301
)
303
302
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
306
305
-- 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
311
310
-- 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