2 RegressionTests define: #Shootout &parents: {TestCase}.
4 "Exercise the Computer Language Shootout benchmarks to ensure they are
5 running correctly. The benchmarks themselves can be found in
6 tests/benchmark/shootout.slate.
8 The individual benchmarks are loaded independently from
9 benchmark/shootout.slate so that there is no requirement
12 load: 'tests/benchmark/ackermann.slate'.
13 load: 'tests/benchmark/binarytrees.slate'.
14 load: 'tests/benchmark/fannkuch.slate'.
15 load: 'tests/benchmark/harmonic.slate'.
16 load: 'tests/benchmark/mandelbrot.slate'.
17 load: 'tests/benchmark/nbody.slate'.
18 load: 'tests/benchmark/nsieve.slate'.
19 load: 'tests/benchmark/nsievebits.slate'.
20 load: 'tests/benchmark/pidigits.slate'.
21 load: 'tests/benchmark/random.slate'.
22 load: 'tests/benchmark/spectralnorm.slate'.
23 load: 'tests/benchmark/sumfile.slate'.
24 load: 'tests/benchmark/takfp.slate'.
26 t@(RegressionTests Shootout traits) ackermann
27 "Integer recursive function performance."
29 t assert: (3 ackermann: 4) = 125.
32 t@(RegressionTests Shootout traits) binarytrees
33 "Allocate and deallocate many binary trees."
35 t assert: ((benchmark TreeNode bottomUpTree: 0 depth: 7) checkItem) = -1.
37 0 below: 10 do: [| :i |
38 c: (c + (benchmark TreeNode bottomUpTree: i depth: 5) checkItem).
39 c: (c + (benchmark TreeNode bottomUpTree: (-1 * i) depth: 5) checkItem).
44 t@(RegressionTests Shootout traits) fannkuch
45 "Indexed-access to tiny integer-sequence."
47 t assert: (7 fannkuch) = 16.
48 t assert: (8 fannkuch) = 22.
51 t@(RegressionTests Shootout traits) harmonic
52 "Calculate the partial sum of the Harmonic series."
54 t assert: ((5 partialSum) as: String) = '2.283333'.
55 t assert: ((10 partialSum) as: String) = '2.928968'.
56 t assert: ((20 partialSum) as: String) = '3.597739'.
57 t assert: ((1000 partialSum) as: String) = '7.485478'.
58 t assert: ((10000 partialSum) as: String) = '9.787613'.
61 t@(RegressionTests Shootout traits) nbody
62 "Double-precision N-body simulation."
64 t assert: ((0 nbodies) as: String) = '-0.169075'.
65 t assert: ((1000 nbodies) as: String) = '-0.169086'.
68 t@(RegressionTests Shootout traits) nsieve
69 "Indexed access to a boolean sequence."
71 t assert: (40000 nsieve) = 4203.
72 t assert: (20000 nsieve) = 2262.
73 t assert: (10000 nsieve) = 1229.
74 t assert: (1 primes) = 2262.
75 t assert: (2 primes) = 4203.
78 t@(RegressionTests Shootout traits) nsievebits
79 "Indexed access to a boolean sequence."
81 t assert: (40000 nsievebits) = 4203.
82 t assert: (20000 nsievebits) = 2262.
83 t assert: (10000 nsievebits) = 1229.
84 t assert: (1 bitprimes) = 2262.
85 t assert: (2 bitprimes) = 4203.
88 t@(RegressionTests Shootout traits) pidigits
89 "Streaming arbitrary-precision arithmetic."
91 27 pidigits. "TODO: Diff output with gold file."
94 t@(RegressionTests Shootout traits) random
95 "Generate random floating-point numbers."
97 t assert: ((RandomNumber to: 100 repeat: 1000) as: String) = '8.163295'.
100 t@(RegressionTests Shootout traits) spectralnorm
101 "Eigenvalue using the power method."
103 t assert: (100 spectralnorm) = '1.27422'
106 t@(RegressionTests Shootout traits) sumfile
107 "Read lines, parse and sum integers."
109 t assert: ('tests/benchmark/sumfile.in' sumfile) = 500.
112 t@(RegressionTests Shootout traits) takfp
113 "Floating-point recursive function performance."
115 t assert: (4 takfp) = 5.0.
116 t assert: (5 takfp) = 10.0.
117 t assert: (6 takfp) = 7.0.
118 t assert: (7 takfp) = 14.0.
119 t assert: (8 takfp) = 9.0.
122 tc@(RegressionTests Shootout traits) suite
123 [tc suiteForSelectors: {