Wolfgang Jeltsch pushed to branch wip/jeltsch/gbc-file-size-tests at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • testsuite/tests/perf/size/Makefile
    ... ... @@ -9,3 +9,12 @@ size_hello_artifact_gzip:
    9 9
     size_hello_unicode_gzip:
    
    10 10
     	'$(TEST_HC)' $(TEST_HC_OPTS) ./size_hello_unicode.hs -v0 -fforce-recomp
    
    11 11
     	gzip --best "./size_hello_unicode$(exe_extension_from_python)"
    
    12
    +
    
    13
    +size_bytecode:
    
    14
    +	'$(TEST_HC)' $(TEST_HC_OPTS) bytecode_example.hs -v0 -fforce-recomp \
    
    15
    +	    -fbyte-code -fwrite-byte-code
    
    16
    +
    
    17
    +size_bytecode_optimized:
    
    18
    +	'$(TEST_HC)' $(TEST_HC_OPTS) bytecode_example.hs -v0 -fforce-recomp \
    
    19
    +	    -fbyte-code -fwrite-byte-code \
    
    20
    +	    -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']),
    20 20
       pre_cmd('$MAKE -s --no-print-directory size_hello_unicode_gzip' + ' exe_extension_from_python="' + exe_extension() + '"'), ignore_stdout, ignore_stderr],
    
    21 21
       multimod_compile, ['size_hello_unicode', ''])
    
    22 22
     
    
    23
    +test(
    
    24
    +    'size_bytecode',
    
    25
    +    [
    
    26
    +        extra_files(['bytecode_example.hs']),
    
    27
    +        collect_size(5, 'bytecode_example.gbc'),
    
    28
    +        ignore_stdout,
    
    29
    +        ignore_stderr
    
    30
    +    ],
    
    31
    +    makefile_test,
    
    32
    +    []
    
    33
    +)
    
    34
    +test(
    
    35
    +    'size_bytecode_optimized',
    
    36
    +    [
    
    37
    +        extra_files(['bytecode_example.hs']),
    
    38
    +        collect_size(5, 'bytecode_example.gbc'),
    
    39
    +        ignore_stdout,
    
    40
    +        ignore_stderr
    
    41
    +    ],
    
    42
    +    makefile_test,
    
    43
    +    []
    
    44
    +)
    
    45
    +
    
    23 46
     size_acceptance_threshold = 100
    
    24 47
     
    
    25 48
     test('array_dir'           ,[collect_size_ghc_pkg(size_acceptance_threshold , 'array')]           , static_stats , [] )
    

  • testsuite/tests/perf/size/bytecode_example.hs
    1
    +-- | A reduced variant of the example used by the @show-bytecode@ tests.
    
    2
    +module Example where
    
    3
    +
    
    4
    +import Numeric.Natural (Natural)
    
    5
    +
    
    6
    +fibonaccis :: [Natural]
    
    7
    +fibonaccis = 0 : positiveFibonaccis where
    
    8
    +
    
    9
    +    positiveFibonaccis :: [Natural]
    
    10
    +    positiveFibonaccis = 1 : zipWith (+) fibonaccis positiveFibonaccis
    
    11
    +
    
    12
    +divides :: Integral a => a -> a -> Bool
    
    13
    +k `divides` n = n `mod` k == 0
    
    14
    +
    
    15
    +primes :: [Natural]
    
    16
    +primes = 2 : filter isPrime [3 ..] where
    
    17
    +
    
    18
    +    isPrime :: Natural -> Bool
    
    19
    +    isPrime n = not (any (`divides` n) (takeWhile ((<= n) . (^ 2)) primes))
    
    20
    +
    
    21
    +data BinTree a b = Leaf a | Node (BinTree a b) b (BinTree a b)
    
    22
    +
    
    23
    +data PerfectTree a = PerfectTree a | Nested (PerfectTree (a, a))