Skip to content

Commit

Permalink
fix(sut): the unit for service time was wrong.
Browse files Browse the repository at this point in the history
  • Loading branch information
symbiont-stevan-andjelkovic committed Mar 10, 2022
1 parent d8c776e commit 25e229b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/sut/dumblog/src/Dumblog/Journal/Worker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@ timeIt metrics action = do
result <- action
!endTime <- getCurrentTime
Metrics.measure metrics ServiceTime
-- `diffUTCTime` has a precision of 10^-12 s, so after multiplying with 10^9
-- we get milliseconds.
(realToFrac (diffUTCTime endTime startTime * 1e9))
(realToFrac (diffUTCTime endTime startTime * 1e6)) -- µs.
return result

wakeUpFrontend :: Blocker (Either Response Response) -> Int -> Either Response Response
Expand Down
16 changes: 9 additions & 7 deletions src/sut/dumblog/src/Dumblog/Metrics/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module Dumblog.Metrics.Main where
import Control.Monad (forever)
import Control.Concurrent (threadDelay)
import Text.Printf (printf)
import GHC.IO.Encoding (setLocaleEncoding, utf8)

import Dumblog.Journal.Metrics
import Journal.Internal.Metrics
Expand All @@ -13,6 +14,7 @@ import Journal.Internal.Metrics

metricsMain :: IO ()
metricsMain = forever $ do
setLocaleEncoding utf8 -- Otherwise we can't print µ...
metrics <- newMetrics dumblogSchema "/tmp/dumblog.metrics"
putStrLn ansiClearScreen
mMin <- percentile metrics ServiceTime 0
Expand All @@ -23,13 +25,13 @@ metricsMain = forever $ do
m9999 <- percentile metrics ServiceTime 99.99
mMax <- percentile metrics ServiceTime 100
putStrLn "Service time:"
putStrLn (maybe "N/A" (printf " min %10.2f ms") mMin)
putStrLn (maybe "N/A" (printf " med %10.2f ms") mMed)
putStrLn (maybe "N/A" (printf " 90 %10.2f ms") m90)
putStrLn (maybe "N/A" (printf " 99 %10.2f ms") m99)
putStrLn (maybe "N/A" (printf " 99.9 %10.2f ms") m999)
putStrLn (maybe "N/A" (printf " 99.99 %10.2f ms") m9999)
putStrLn (maybe "N/A" (printf " max %10.2f ms") mMax)
putStrLn (maybe "N/A" (printf " min %10.2f µs") mMin)
putStrLn (maybe "N/A" (printf " med %10.2f µs") mMed)
putStrLn (maybe "N/A" (printf " 90 %10.2f µs") m90)
putStrLn (maybe "N/A" (printf " 99 %10.2f µs") m99)
putStrLn (maybe "N/A" (printf " 99.9 %10.2f µs") m999)
putStrLn (maybe "N/A" (printf " 99.99 %10.2f µs") m9999)
putStrLn (maybe "N/A" (printf " max %10.2f µs") mMax)
cnt <- count metrics ServiceTime
putStrLn (printf " count %10d" cnt)
threadDelay 1_000_000
Expand Down

0 comments on commit 25e229b

Please sign in to comment.