@@ -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
@@ -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)
@@ -295,16 +294,17 @@ ruleStats = Map.fromListWith (<>) . collect
295
294
mkOutcome startLine endLine =
296
295
let time =
297
296
maybe 1 realToFrac $
298
- (diffUTCTime
297
+ ( diffUTCTime
299
298
<$> fmap systemToUTCTime endLine. timestamp
300
299
<*> fmap systemToUTCTime startLine. timestamp
301
300
)
302
301
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