From 25e229bd31ec61134ef52099ec5732e481110c9f Mon Sep 17 00:00:00 2001 From: Stevan Andjelkovic Date: Thu, 10 Mar 2022 10:43:10 +0100 Subject: [PATCH] fix(sut): the unit for service time was wrong. --- src/sut/dumblog/src/Dumblog/Journal/Worker.hs | 4 +--- src/sut/dumblog/src/Dumblog/Metrics/Main.hs | 16 +++++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sut/dumblog/src/Dumblog/Journal/Worker.hs b/src/sut/dumblog/src/Dumblog/Journal/Worker.hs index 59034a95..00b459cf 100644 --- a/src/sut/dumblog/src/Dumblog/Journal/Worker.hs +++ b/src/sut/dumblog/src/Dumblog/Journal/Worker.hs @@ -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 diff --git a/src/sut/dumblog/src/Dumblog/Metrics/Main.hs b/src/sut/dumblog/src/Dumblog/Metrics/Main.hs index 2e539d0a..dbe9175d 100644 --- a/src/sut/dumblog/src/Dumblog/Metrics/Main.hs +++ b/src/sut/dumblog/src/Dumblog/Metrics/Main.hs @@ -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 @@ -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 @@ -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