summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2020-12-07 13:19:28 +0000
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-03-03 08:12:29 -0500
commitd89deeba47ce04a5198a71fa4cbc203fe2c90794 (patch)
tree8f879bbb0774ce686e1688cc638ef22179babf51 /testsuite
parentd8dc0f96237fe6fe7081c04727c7c2573477e5cb (diff)
downloadhaskell-d89deeba47ce04a5198a71fa4cbc203fe2c90794.tar.gz
Profiling: Allow heap profiling to be controlled dynamically.
This patch exposes three new functions in `GHC.Profiling` which allow heap profiling to be enabled and disabled dynamically. 1. startHeapProfTimer - Starts heap profiling with the given RTS options 2. stopHeapProfTimer - Stops heap profiling 3. requestHeapCensus - Perform a heap census on the next context switch, regardless of whether the timer is enabled or not.
Diffstat (limited to 'testsuite')
-rw-r--r--testsuite/tests/profiling/should_run/all.T6
-rw-r--r--testsuite/tests/profiling/should_run/dynamic-prof.hs13
-rw-r--r--testsuite/tests/profiling/should_run/dynamic-prof2.hs13
-rw-r--r--testsuite/tests/profiling/should_run/dynamic-prof3.hs15
4 files changed, 47 insertions, 0 deletions
diff --git a/testsuite/tests/profiling/should_run/all.T b/testsuite/tests/profiling/should_run/all.T
index fbe1379e92..9f1fa67e1e 100644
--- a/testsuite/tests/profiling/should_run/all.T
+++ b/testsuite/tests/profiling/should_run/all.T
@@ -8,6 +8,12 @@ test('heapprof002',
test('T11489', [req_profiling], makefile_test, ['T11489'])
+test('dynamic-prof', [], compile_and_run, [''])
+
+test('dynamic-prof2', [only_ways(['normal']), extra_run_opts('+RTS -hT --no-automatic-heap-samples')], compile_and_run, [''])
+
+test('dynamic-prof3', [only_ways(['normal']), extra_run_opts('+RTS -hT --no-automatic-heap-samples')], compile_and_run, [''])
+
# Below this line, run tests only with profiling ways.
setTestOpts(req_profiling)
setTestOpts(extra_ways(['prof', 'ghci-ext-prof']))
diff --git a/testsuite/tests/profiling/should_run/dynamic-prof.hs b/testsuite/tests/profiling/should_run/dynamic-prof.hs
new file mode 100644
index 0000000000..243e094877
--- /dev/null
+++ b/testsuite/tests/profiling/should_run/dynamic-prof.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE BangPatterns #-}
+module Main where
+
+import GHC.Profiling
+import Control.Exception
+
+main = do
+ let !t = [0..1000000]
+ evaluate (length t)
+ requestHeapCensus
+ evaluate (length t)
+
+
diff --git a/testsuite/tests/profiling/should_run/dynamic-prof2.hs b/testsuite/tests/profiling/should_run/dynamic-prof2.hs
new file mode 100644
index 0000000000..243e094877
--- /dev/null
+++ b/testsuite/tests/profiling/should_run/dynamic-prof2.hs
@@ -0,0 +1,13 @@
+{-# LANGUAGE BangPatterns #-}
+module Main where
+
+import GHC.Profiling
+import Control.Exception
+
+main = do
+ let !t = [0..1000000]
+ evaluate (length t)
+ requestHeapCensus
+ evaluate (length t)
+
+
diff --git a/testsuite/tests/profiling/should_run/dynamic-prof3.hs b/testsuite/tests/profiling/should_run/dynamic-prof3.hs
new file mode 100644
index 0000000000..f5a17bef8d
--- /dev/null
+++ b/testsuite/tests/profiling/should_run/dynamic-prof3.hs
@@ -0,0 +1,15 @@
+{-# LANGUAGE BangPatterns #-}
+module Main where
+
+import GHC.Profiling
+import Control.Exception
+
+main = do
+ startHeapProfTimer
+ let !t = [0..1000000]
+ evaluate (length t)
+ requestHeapCensus
+ evaluate (length t)
+ stopHeapProfTimer
+
+