From 8e1fa4981f2ee0e8c7915b664ec44e15846b034e Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Wed, 17 Feb 2021 15:02:39 +0100 Subject: [PATCH] Add memory stats to benchmark --- testsuite/lpgf/README.md | 7 ++++--- testsuite/lpgf/bench.hs | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/testsuite/lpgf/README.md b/testsuite/lpgf/README.md index 67ed82486..4a02416fd 100644 --- a/testsuite/lpgf/README.md +++ b/testsuite/lpgf/README.md @@ -28,7 +28,8 @@ Comparing PGF, PGF2, LPGF along following criteria: ### Running ``` -stack build --test --bench --no-run-tests --no-run-benchmarks && time stack bench -stack build --test --bench --no-run-tests --no-run-benchmarks && time PGF_ONLY=1 stack bench -stack build --test --bench --no-run-tests --no-run-benchmarks && time LPGF_ONLY=1 stack bench +stack build --test --bench --no-run-tests --no-run-benchmarks +stack bench --benchmark-arguments "+RTS -T -RTS" +PGF_ONLY=1 stack bench --benchmark-arguments "+RTS -T -RTS" +LPGF_ONLY=1 stack bench --benchmark-arguments "+RTS -T -RTS" ``` diff --git a/testsuite/lpgf/bench.hs b/testsuite/lpgf/bench.hs index 16e76b117..65dc96e6b 100644 --- a/testsuite/lpgf/bench.hs +++ b/testsuite/lpgf/bench.hs @@ -19,6 +19,8 @@ import System.Environment (lookupEnv) import System.FilePath ((), takeBaseName, takeExtension) import Text.Printf (printf) +import GHC.Stats + dir :: FilePath dir = "testsuite" "lpgf" @@ -61,6 +63,10 @@ main = do time "linearise LPGF" (return $ length $ linLPGF lpgf trees) return () + stats <- getRTSStats + printf "Max live memory: %s\n" (convertSize (read (show (max_live_bytes stats)))) + printf "Max used memory: %s\n" (convertSize (read (show (max_mem_in_use_bytes stats)))) + time :: String -> IO a -> IO a time desc io = do start <- getCurrentTime