Wolfgang Jeltsch pushed to branch wip/jeltsch/gbc-file-size-tests at Glasgow Haskell Compiler / GHC Commits: ca6ad379 by Wolfgang Jeltsch at 2026-11-24T21:06:47+02:00 Add tests that check `*.gbc` file sizes Resolves #27643. - - - - - 3 changed files: - testsuite/tests/perf/size/Makefile - testsuite/tests/perf/size/all.T - + testsuite/tests/perf/size/bytecode_example.hs Changes: ===================================== testsuite/tests/perf/size/Makefile ===================================== @@ -9,3 +9,12 @@ size_hello_artifact_gzip: size_hello_unicode_gzip: '$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_unicode.hs -v0 -fforce-recomp gzip --best "./size_hello_unicode$(exe_extension_from_python)" + +size_bytecode: + '$(TEST_HC)' $(TEST_HC_OPTS) bytecode_example.hs -v0 -fforce-recomp \ + -fbyte-code -fwrite-byte-code + +size_bytecode_optimized: + '$(TEST_HC)' $(TEST_HC_OPTS) bytecode_example.hs -v0 -fforce-recomp \ + -fbyte-code -fwrite-byte-code \ + -fno-unoptimized-core-for-interpreter -O2 ===================================== testsuite/tests/perf/size/all.T ===================================== @@ -20,6 +20,29 @@ test('size_hello_unicode_gzip', [extra_files(['./size_hello_unicode.hs']), pre_cmd('$MAKE -s --no-print-directory size_hello_unicode_gzip' + ' exe_extension_from_python="' + exe_extension() + '"'), ignore_stdout, ignore_stderr], multimod_compile, ['size_hello_unicode', '']) +test( + 'size_bytecode', + [ + extra_files(['bytecode_example.hs']), + collect_size(5, 'bytecode_example.gbc'), + ignore_stdout, + ignore_stderr + ], + makefile_test, + [] +) +test( + 'size_bytecode_optimized', + [ + extra_files(['bytecode_example.hs']), + collect_size(5, 'bytecode_example.gbc'), + ignore_stdout, + ignore_stderr + ], + makefile_test, + [] +) + size_acceptance_threshold = 100 test('array_dir' ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')] , static_stats , [] ) ===================================== testsuite/tests/perf/size/bytecode_example.hs ===================================== @@ -0,0 +1,23 @@ +-- | A reduced variant of the example used by the @show-bytecode@ tests. +module Example where + +import Numeric.Natural (Natural) + +fibonaccis :: [Natural] +fibonaccis = 0 : positiveFibonaccis where + + positiveFibonaccis :: [Natural] + positiveFibonaccis = 1 : zipWith (+) fibonaccis positiveFibonaccis + +divides :: Integral a => a -> a -> Bool +k `divides` n = n `mod` k == 0 + +primes :: [Natural] +primes = 2 : filter isPrime [3 ..] where + + isPrime :: Natural -> Bool + isPrime n = not (any (`divides` n) (takeWhile ((<= n) . (^ 2)) primes)) + +data BinTree a b = Leaf a | Node (BinTree a b) b (BinTree a b) + +data PerfectTree a = PerfectTree a | Nested (PerfectTree (a, a)) View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6ad3790743c2a6be5f0399914699b6... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/ca6ad3790743c2a6be5f0399914699b6... You're receiving this email because of your account on gitlab.haskell.org. Manage all notifications: https://gitlab.haskell.org/-/profile/notifications | Help: https://gitlab.haskell.org/help