From d3e0124c1157a4a423d86a1dc1d7e82c6d32ef06 Mon Sep 17 00:00:00 2001
From: Finley McIlwaine <finleymcilwaine@gmail.com>
Date: Tue, 22 Aug 2023 12:10:38 -0600
Subject: [PATCH] Add a test checking overhead of -finfo-table-map

We want to make sure we don't end up with poor codegen performance resulting from
-finfo-table-map again as in #23103. This test adds a performance test tracking
total allocations while compiling ExactPrint with -finfo-table-map.
---
 testsuite/tests/profiling/perf/Makefile        |  3 +++
 testsuite/tests/profiling/perf/T23103/all.T    | 18 ++++++++++++++++++
 .../perf/T23103/info_table_map_perf.stderr     |  5 +++++
 3 files changed, 26 insertions(+)
 create mode 100644 testsuite/tests/profiling/perf/Makefile
 create mode 100644 testsuite/tests/profiling/perf/T23103/all.T
 create mode 100644 testsuite/tests/profiling/perf/T23103/info_table_map_perf.stderr

diff --git a/testsuite/tests/profiling/perf/Makefile b/testsuite/tests/profiling/perf/Makefile
new file mode 100644
index 000000000000..bced01ff9b62
--- /dev/null
+++ b/testsuite/tests/profiling/perf/Makefile
@@ -0,0 +1,3 @@
+TOP=../../..
+include $(TOP)/mk/boilerplate.mk
+include $(TOP)/mk/test.mk
\ No newline at end of file
diff --git a/testsuite/tests/profiling/perf/T23103/all.T b/testsuite/tests/profiling/perf/T23103/all.T
new file mode 100644
index 000000000000..891b32383ffb
--- /dev/null
+++ b/testsuite/tests/profiling/perf/T23103/all.T
@@ -0,0 +1,18 @@
+test(
+    'info_table_map_perf',
+    [
+        collect_compiler_stats('bytes allocated',10),
+        extra_files(
+            [
+                '../../../../../utils/check-exact/ExactPrint.hs',
+                '../../../../../utils/check-exact/Lookup.hs',
+                '../../../../../utils/check-exact/Orphans.hs',
+                '../../../../../utils/check-exact/Types.hs',
+                '../../../../../utils/check-exact/Utils.hs',
+            ]
+        ),
+        js_skip
+    ],
+    multimod_compile,
+    ['ExactPrint.hs', '-package ghc -O -finfo-table-map']
+)
diff --git a/testsuite/tests/profiling/perf/T23103/info_table_map_perf.stderr b/testsuite/tests/profiling/perf/T23103/info_table_map_perf.stderr
new file mode 100644
index 000000000000..bb6a7c12b1ea
--- /dev/null
+++ b/testsuite/tests/profiling/perf/T23103/info_table_map_perf.stderr
@@ -0,0 +1,5 @@
+[1 of 5] Compiling Orphans          ( Orphans.hs, Orphans.o )
+[2 of 5] Compiling Types            ( Types.hs, Types.o )
+[3 of 5] Compiling Lookup           ( Lookup.hs, Lookup.o )
+[4 of 5] Compiling Utils            ( Utils.hs, Utils.o )
+[5 of 5] Compiling ExactPrint       ( ExactPrint.hs, ExactPrint.o )
-- 
GitLab