From 8f5033e4cec35e598c5a64df5047872a5d964de7 Mon Sep 17 00:00:00 2001 From: "John J. Camilleri" Date: Tue, 9 Mar 2021 08:36:35 +0100 Subject: [PATCH] Add notes on profiling --- testsuite/lpgf/README.md | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/testsuite/lpgf/README.md b/testsuite/lpgf/README.md index febdd5d6c..acfda2a31 100644 --- a/testsuite/lpgf/README.md +++ b/testsuite/lpgf/README.md @@ -61,11 +61,31 @@ stack bench --benchmark-arguments "run lpgf Foods.lpgf testsuite/lpgf/foods/Food stack build --test --bench --no-run-tests --no-run-benchmarks && stack bench --benchmark-arguments "compile pgf testsuite/lpgf/phrasebook/Phrasebook*.gf +RTS -T -RTS" && stack bench --benchmark-arguments "compile lpgf testsuite/lpgf/phrasebook/Phrasebook*.gf +RTS -T -RTS" && -stack bench --benchmark-arguments "run pgf Foods.pgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" && -stack bench --benchmark-arguments "run pgf2 Foods.pgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" && -stack bench --benchmark-arguments "run lpgf Foods.lpgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" +stack bench --benchmark-arguments "run pgf Phrasebook.pgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" && +stack bench --benchmark-arguments "run pgf2 Phrasebook.pgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" && +stack bench --benchmark-arguments "run lpgf Phrasebook.lpgf testsuite/lpgf/phrasebook/Phrasebook-10000.trees +RTS -T -RTS" ``` +## Profiling + +``` +stack bench --work-dir .stack-work-profile --profile --benchmark-arguments "compile lpgf testsuite/lpgf/phrasebook/PhrasebookFre.gf +RTS -T -p -h -RTS" +``` + +Produced files: +- `lpgf-bench.prof` - total time and memory allocation (`-p`) +- `lpgf-bench.hp` - heap profile (`-h`) + +``` +stack exec -- hp2ps -c lpgf-bench.hp && open lpgf-bench.ps +``` + +**Resources** + +- https://downloads.haskell.org/ghc/8.6.5/docs/html/users_guide/profiling.html +- http://book.realworldhaskell.org/read/profiling-and-optimization.html +- https://wiki.haskell.org/Performance + # Notes on compilation ## 1 (see unittests/Params4)