From c36862a25f6969770f7aca9c35225a136b917e43 Mon Sep 17 00:00:00 2001 From: Adithya Kumar Date: Mon, 13 Nov 2023 16:18:08 +0000 Subject: [PATCH] Install exit handlers --- haskell-perf.cabal | 1 + stat-collector-src/Main.hs | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/haskell-perf.cabal b/haskell-perf.cabal index e49720f..e4dd3fb 100644 --- a/haskell-perf.cabal +++ b/haskell-perf.cabal @@ -129,3 +129,4 @@ executable stat-collector , streamly , containers , ansi-terminal + , unix diff --git a/stat-collector-src/Main.hs b/stat-collector-src/Main.hs index 64098f5..b655a63 100644 --- a/stat-collector-src/Main.hs +++ b/stat-collector-src/Main.hs @@ -25,6 +25,7 @@ import Streamly.Internal.Data.Tuple.Strict (Tuple3Fused' (Tuple3Fused')) import Streamly.Unicode.String (str) import System.IO (hFlush, stdout, stdin) import Text.Read (readMaybe) +import System.Posix.Signals (installHandler, Handler(Catch), sigINT, sigTERM) import qualified Data.Map as Map import qualified Streamly.Data.Fold as Fold @@ -285,12 +286,13 @@ printSlidingStats winSizeList counter rowsOnPage strm = main :: IO () main = do let rowsOnPage = 50 - windowSize = 30 + windowSize = 50 counter = CpuTime - freqMeasurementWindow = 30 + freqMeasurementWindow = 5 tidToInstrument = 21 mainTag = "server" lastCounter = Allocated + _ <- installHandler sigINT (Catch $ ANSI.showCursor) Nothing ANSI.hideCursor ANSI.clearScreen (winSizeList, rest) <- Stream.unfold Handle.chunkReader stdin