fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / benchmark / benchmarks.t
blobcb6a016dfa35df7e78e6869d494a7ad934e45929
1 #!perl
2 # Copyright (C) 2006, Parrot Foundation.
3 # $Id$
5 use strict;
6 use warnings;
7 use lib qw( lib . ../lib ../../lib );
9 use Parrot::Test;
10 use Test::More;
12 =head1 NAME
14 t/benchmark/benchmarks.t - test scripts in examples/benchmarks
16 =head1 SYNOPSIS
18     prove t/benchmark/benchmarks.t
20 =head1 DESCRIPTION
22 Called by 'make benchmark_tests'.
24 =cut
26 # Expected output from scripts in 'examples/benchmarks'.
27 # The expected out is needed for checking results with pir_output_is() and pir_output_like().
28 my %outputs = (
29     q{addit.pir}        => qq(21001097.97\n),
30     q{addit.pasm}       => qq(21001097.97\n),
31     q{addit2.pir}       => qq(21001097.97\n),
32     q{array_access.pir} => qr/
33 1\s\*\s1000\s=\s1000\n
34 100\s\*\s1000\s=\s100000\n
35 FixedFloatArray:\s\d+\.\d+s\n
37 1\s\*\s1000\s=\s1000\n
38 100\s\*\s1000\s=\s100000\n
39 FixedIntegerArray:\s\d+\.\d+s\n
41 1\s\*\s1000\s=\s1000\n
42 100\s\*\s1000\s=\s100000\n
43 FixedPMCArray:\s\d+\.\d+s\n
45 1\s\*\s1000\s=\s1000\n
46 100\s\*\s1000\s=\s100000\n
47 FixedStringArray:\s\d+\.\d+s\n
49 1\s\*\s1000\s=\s1000\n
50 100\s\*\s1000\s=\s100000\n
51 ResizableFloatArray:\s\d+\.\d+s\n
53 1\s\*\s1000\s=\s1000\n
54 100\s\*\s1000\s=\s100000\n
55 ResizableIntegerArray:\s\d+\.\d+s\n
57 1\s\*\s1000\s=\s1000\n
58 100\s\*\s1000\s=\s100000\n
59 ResizablePMCArray:\s\d+\.\d+s\n
61 1\s\*\s1000\s=\s1000\n
62 100\s\*\s1000\s=\s100000\n
63 ResizableStringArray:\s\d+\.\d+s\n
65 1\s\*\s1000\s=\s1000\n
66 100\s\*\s1000\s=\s100000\n
67 FixedPMCArray:\s\d+\.\d+s\n
68 \s+$/x,
69     q{arriter.pir}     => qq(100000\n100000\n100000\n111111\n),
70     q{arriter_o1.pir}  => qq(100000\n100000\n100000\n111111\n),
71     q{bench_newp.pasm} => qr/^\d+\.\d+\sseconds.\s\d+\.\d+\sloops\/sec\n
72         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
73         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
74         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
75         Copying\sa\stotal\sof\s\d+\sbytes\n
76         There\sare\s\d+\sactive\sPMC\sstructs\n
77         There\sare\s\d+\stotal\sPMC\sstructs\n
78         There\sare\s\d+\sactive\sBuffer\sstructs\n
79         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
80     q{fib.pir}     => qr/^fib\(28\)\s=\s317811\s\d+\.\d+s$/x,
81     q{freeze.pasm} => qr/^constr.time\s\d+\.\d+\n
82         freeze\stime\s\d+\.\d+\n
83         \s\sthaw\stime\s\d+\.\d+\n
84         Image\slen\s\d+\n
85         ResizablePMCArray\s100000\n$/x,
86     q{gc_alloc_new.pasm} => qr/^\d+\.\d+\sseconds\.\n
87         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
88         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
89         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
90         Copying\sa\stotal\sof\s\d+\sbytes\n
91         There\sare\s\d+\sactive\sBuffer\sstructs\n
92         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
93     q{gc_alloc_reuse.pasm} => qr/^\d+\.\d+\sseconds\.\n
94         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
95         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
96         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
97         Copying\sa\stotal\sof\s\d+\sbytes\n
98         There\sare\s\d+\sactive\sBuffer\sstructs\n
99         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
100     q{gc_generations.pasm} => qr/^\d+\.\d+\sseconds\.\n
101         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
102         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
103         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
104         Copying\sa\stotal\sof\s\d+\sbytes\n
105         There\sare\s\d+\sactive\sBuffer\sstructs\n
106         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
107     q{gc_header_new.pasm} => qr/^\d+\.\d+\sseconds\.\n
108         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
109         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
110         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
111         Copying\sa\stotal\sof\s\d+\sbytes\n
112         There\sare\s\d+\sactive\sBuffer\sstructs\n
113         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
114     q{gc_header_reuse.pasm} => qr/^\d+\.\d+\sseconds\.\n
115         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
116         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
117         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
118         Copying\sa\stotal\sof\s\d+\sbytes\n
119         There\sare\s\d+\sactive\sBuffer\sstructs\n
120         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
121     q{gc_waves_headers.pasm} => qr/^\d+\.\d+\sseconds\.\n
122         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
123         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
124         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
125         Copying\sa\stotal\sof\s\d+\sbytes\n
126         There\sare\s\d+\sactive\sBuffer\sstructs\n
127         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
128     q{gc_waves_sizeable_data.pasm} => qr/^\d+\.\d+\sseconds\.\n
129         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
130         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
131         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
132         Copying\sa\stotal\sof\s\d+\sbytes\n
133         There\sare\s\d+\sactive\sBuffer\sstructs\n
134         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
135     q{gc_waves_sizeable_headers.pasm} => qr/^\d+\.\d+\sseconds\.\n
136         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
137         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
138         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
139         Copying\sa\stotal\sof\s\d+\sbytes\n
140         There\sare\s\d+\sactive\sBuffer\sstructs\n
141         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
142 #omitted because they're slow and doesn't exercise anything novel
143 #    q{mops.pasm} => qr/^Iterations:\s\s\s\s10000000\n
144 #        Estimated\sops:\s20000000\n
145 #        done\n
146 #        Elapsed\stime:\s\s\d+\.\d+\n
147 #        M\sop\/s:\s\s\s\s\s\s\s\s\d+\.\d+\n$/x,
148 #    q(mops_intval.pasm) => qr/^Iterations:\s\s\s\s100000000\n
149 #        Estimated\sops:\s200000000\n
150 #        Elapsed\stime:\s\s\d+\.\d+\n
151 #        M\sop\/s:\s\s\s\s\s\s\s\s\d+\.\d+\n$/x,
152     q{oo1.pir}      => qq(10\n),
153     q{oo2.pir}      => qq(10\n),
154     q{oo3.pir}      => qq(10\n),
155     q{oo4.pasm}     => qq(500000\n),
156     q{oo5.pir}      => qq(10\n),
157     q{oo6.pir}      => qq(500000\n),
158     q{oofib.pir}    => qr/^fib\(24\)\s=\s46368\s\d+\.\d+s$/x,
159     q{overload.pir} => qq(42\n),
160     q{primes.pasm}  => qr/^N\sprimes\sup\sto\s5000\sis:\s669\n
161         last\sis:\s4999\n
162         Elapsed\stime:\s\d+\.\d+\n$/x,
163     q{primes2.pir} => qr/^N\sprimes\scalculated\sto\s500\sis\s96\n
164         last\sis:\s499\n$/x,
165     q{primes2_i.pir} => qr/^N\sprimes\scalculated\sto\s10000\s
166         is\s1230\nlast\sis:\s9973\n$/x,
167     q{primes_i.pasm} => qr/^N\sprimes\sup\sto\s10000\sis:\s1229\n
168         last\sis:\s9973\nElapsed\stime:\s\d+\.\d+\n$/x,
169     q{stress.pasm}     => qr/^A\stotal\sof\s\d+\sGC\sruns\s
170         were\smade\n$/x,
171     q{stress1.pasm} => qr/^\d+\.\d+\n
172         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
173         \d+\.\d+\n
174         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
175         \d+\.\d+\n
176         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
177         \d+\.\d+\n
178         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
179         \d+\.\d+\n
180         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
181         \d+\.\d+\n
182         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
183         \d+\.\d+\n
184         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
185         \d+\.\d+\n
186         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
187         \d+\.\d+\n
188         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
189         \d+\.\d+\n
190         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n$/x,
191     q{stress2.pasm} => qq(),
192     q{stress3.pasm} => qr/^A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
193         \d+\sactive\sPMCs\n
194         \d+\stotal\s\sPMCs\n$/x,
195     q{vpm.pir} => qq(100000;\nl hackerjust another per\n)
198 # These scripts are known to be failing.
199 my %todo = ();
201 plan tests => scalar keys %outputs;
203 foreach ( sort keys %outputs ) {
204 SKIP: {
205         my $bench = Parrot::Test::slurp_file("examples/benchmarks/$_");
206         skip( "Could not slurp $_", 1 ) unless $bench;
208         my @todo = $todo{$_} ? ( todo => $todo{$_} ) : ();
210         if ( ref $outputs{$_} eq 'Regexp' ) {
211             example_output_like( "examples/benchmarks/$_", $outputs{$_}, @todo );
212         }
213         else {
214             example_output_is( "examples/benchmarks/$_", $outputs{$_}, @todo );
215         }
216     }
219 # Local Variables:
220 #   mode: cperl
221 #   cperl-indent-level: 4
222 #   fill-column: 100
223 # End:
224 # vim: expandtab shiftwidth=4: