summaryrefslogtreecommitdiff
path: root/testsuite/tests/perf/compiler/genManyAlternatives
blob: 1035425bd4fdc10c781a0cb068d743998bd7994a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
SIZE=1000
MODULE=ManyAlternatives

# Generates a module with a large number of alternatives that looks
# like this:
#
#   module ManyAlternatives where
#
#   data A1000 = A0
#     | A0001
#     | A0002
#     ...
#     | A1000
#
#   f :: A -> Int
#   f A0001 = 1990001
#   f A0002 = 1990002
#   ...
#   f A1000 = 1991000
#
# The point of this test is to check if we don't regress on #14667 reintroducing
# some code that's quadratic in the number of alternatives.

echo "module $MODULE where" > $MODULE.hs
echo >> $MODULE.hs
echo "data A$SIZE = A0" >> $MODULE.hs
for i in $(seq -w 1 $SIZE); do
  echo "  | A$i" >> $MODULE.hs
done
echo >> $MODULE.hs
echo "f :: A$SIZE -> Int" >> $MODULE.hs
for i in $(seq -w 1 $SIZE); do
  echo "f A$i = 199$i" >> $MODULE.hs
done