@@ -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 )
21
+ import Data.Ord (comparing , Down ( .. ) )
22
22
import Data.Sequence (Seq (.. ))
23
23
import Data.Sequence qualified as Seq
24
24
import Data.Time.Clock
@@ -141,14 +141,14 @@ process TimesPerRule =
141
141
(heading <> ) . map renderResult . ruleStatistics
142
142
where
143
143
heading =
144
- [ " | Rule/Equation | Success | Failure | Abort"
145
- , " |----------------------- | ----------------- | ----------------- | ----------------"
144
+ [ " | Rule/Equation | Success | Failure | Abort"
145
+ , " |----------------------- | ------------------- | ------------------- | --- ----------------"
146
146
]
147
147
renderResult :: (IdContext , RuleStats ) -> BS. ByteString
148
148
renderResult (ctx, stats) =
149
149
BS. pack $
150
150
printf
151
- " | %22s | %3.3fs (%4d ) | %3.3fs (%4d ) | %3.3fs (%4d )"
151
+ " | %22s | %10.6fs (%5d ) | %10.6fs (%5d ) | %10.6fs (%5d )"
152
152
(show ctx)
153
153
stats. tSuccess
154
154
stats. nSuccess
@@ -220,7 +220,7 @@ findRecursions ls = Map.assocs resultMap
220
220
221
221
ruleStatistics :: [LogLine ] -> [(IdContext , RuleStats )]
222
222
ruleStatistics =
223
- sortBy (comparing $ allTimes . snd )
223
+ sortBy (comparing ( Down . allTimes . snd ) )
224
224
. Map. assocs
225
225
. ruleStats
226
226
where
@@ -279,8 +279,7 @@ ruleStats = Map.fromListWith (<>) . collect
279
279
fromCtxSpan :: Seq CLContext -> [LogLine ] -> (RuleStats , [LogLine ])
280
280
fromCtxSpan prefix ls
281
281
| null prefixLines =
282
- (RuleStats 0 0 0 0 0 0 , ls) -- HACK
283
- -- error "Should have at least one line with the prefix" -- see above
282
+ error " Should have at least one line with the prefix" -- see above
284
283
| otherwise =
285
284
(mkOutcome (head prefixLines) (last prefixLines), rest)
286
285
where
@@ -289,22 +288,30 @@ ruleStats = Map.fromListWith (<>) . collect
289
288
hasPrefix :: LogLine -> Bool
290
289
hasPrefix = (== prefix) . Seq. take len . (. context)
291
290
292
- (prefixLines, rest) = span ( not . hasPrefix) ls
291
+ (prefixLines, rest) = span hasPrefix ls
293
292
294
293
mkOutcome :: LogLine -> LogLine -> RuleStats
295
294
mkOutcome startLine endLine =
296
295
let time =
297
- maybe 1 realToFrac $
296
+ maybe
297
+ 1
298
+ realToFrac
298
299
(diffUTCTime
299
300
<$> fmap systemToUTCTime endLine. timestamp
300
301
<*> fmap systemToUTCTime startLine. timestamp
301
302
)
302
- in case endLine. context of
303
- _ :|> CLNullary CtxSuccess ->
303
+ in case Seq. drop len endLine. context of
304
+ CLNullary CtxSuccess :<| _ ->
304
305
RuleStats 1 0 0 time 0 0
306
+ -- rewrite failures
305
307
_ :|> CLNullary CtxFailure ->
306
308
RuleStats 0 1 0 0 time 0
307
- _ :|> CLNullary CtxAbort ->
309
+ _ :|> CLNullary CtxIndeterminate ->
310
+ RuleStats 0 0 1 0 0 time
311
+ -- equation failures
312
+ _ :|> CLNullary CtxContinue ->
313
+ RuleStats 0 1 0 0 time 0
314
+ _ :|> CLNullary CtxBreak ->
308
315
RuleStats 0 0 1 0 0 time
309
316
other -> -- case not covered...
310
- error $ " Unexpected last context " <> show ( Seq. drop len other)
317
+ error $ " Unexpected last context " <> show other
0 commit comments