Skip to content

Commit a29af8d

Browse files
committed
Add the freq determining offset to get the exact stats
1 parent c36862a commit a29af8d

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

stat-collector-src/Main.hs

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -231,20 +231,23 @@ printTable rows = do
231231
fillRow r = zipWith (\n x -> fill n x) maxLengths r
232232

233233
statsToTable
234-
:: [(EventId, Int)]
234+
:: Int
235+
-> [(EventId, Int)]
235236
-> Counter
236237
-> [(EventId, Int)]
237238
-> Map EventId StatResult
238239
-> [[String]]
239-
statsToTable winSizeList counter keyTracker mp =
240+
statsToTable freqMeasurementWindow winSizeList counter keyTracker mp =
240241
["Tag", "Mean", "Min", "Max", "Count", "Window"]
241242
: map
242243
(\(evId@(EventId _ t _), (me, rg)) ->
243244
[ t
244245
, showFFloat (Just 2) me ""
245246
, showMaybe (fmap fst rg)
246247
, showMaybe (fmap snd rg)
247-
, show $ fromJust $ lookup evId keyTracker
248+
, show
249+
$ (+freqMeasurementWindow)
250+
$ fromJust $ lookup evId keyTracker
248251
, show $ fromJust $ lookup evId winSizeList
249252
])
250253
(sortBy sorterFunc
@@ -262,19 +265,25 @@ statsToTable winSizeList counter keyTracker mp =
262265
_ -> error "Key not found"
263266

264267
printSlidingStats
265-
:: [(EventId, Int)]
268+
:: Int
269+
-> [(EventId, Int)]
266270
-> Counter
267271
-> Int
268272
-> Stream IO ([(EventId, Int)], Map EventId StatResult)
269273
-> IO ()
270-
printSlidingStats winSizeList counter rowsOnPage strm =
274+
printSlidingStats freqMeasurementWindow winSizeList counter rowsOnPage strm =
271275
Stream.fold
272276
(Fold.drainMapM
273277
(\(order, mp) -> do
274278
ANSI.setCursorPosition 0 0
275279
printTable
276280
(take rowsOnPage
277-
(statsToTable winSizeList counter order mp))
281+
(statsToTable
282+
freqMeasurementWindow
283+
winSizeList
284+
counter
285+
order
286+
mp))
278287
hFlush stdout
279288
))
280289
strm
@@ -313,4 +322,4 @@ main = do
313322
<$> Fold.latest)))
314323
scanStats winSizeList rest
315324
& Stream.sampleIntervalEnd 2
316-
& printSlidingStats winSizeList counter rowsOnPage
325+
& printSlidingStats freqMeasurementWindow winSizeList counter rowsOnPage

0 commit comments

Comments
 (0)