[TT #969][t] Convert t/pmc/float.t to PIR, flh++
[parrot.git] / t / benchmark / benchmarks.t
blobc0029e404f892a706f68623bd173120f47ec9ee3
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 Array:\s\d+\.\d+s\n
37 1\s\*\s1000\s=\s1000\n
38 100\s\*\s1000\s=\s100000\n
39 FixedFloatArray:\s\d+\.\d+s\n
41 1\s\*\s1000\s=\s1000\n
42 100\s\*\s1000\s=\s100000\n
43 FixedIntegerArray:\s\d+\.\d+s\n
45 1\s\*\s1000\s=\s1000\n
46 100\s\*\s1000\s=\s100000\n
47 FixedPMCArray:\s\d+\.\d+s\n
49 1\s\*\s1000\s=\s1000\n
50 100\s\*\s1000\s=\s100000\n
51 FixedStringArray:\s\d+\.\d+s\n
53 1\s\*\s1000\s=\s1000\n
54 100\s\*\s1000\s=\s100000\n
55 ResizableFloatArray:\s\d+\.\d+s\n
57 1\s\*\s1000\s=\s1000\n
58 100\s\*\s1000\s=\s100000\n
59 ResizableIntegerArray:\s\d+\.\d+s\n
61 1\s\*\s1000\s=\s1000\n
62 100\s\*\s1000\s=\s100000\n
63 ResizablePMCArray:\s\d+\.\d+s\n
65 1\s\*\s1000\s=\s1000\n
66 100\s\*\s1000\s=\s100000\n
67 ResizableStringArray:\s\d+\.\d+s\n
69 1\s\*\s1000\s=\s1000\n
70 100\s\*\s1000\s=\s100000\n
71 FixedPMCArray:\s\d+\.\d+s\n
72 \s+$/x,
73     q{arriter.pir}     => qq(100000\n100000\n100000\n111111\n),
74     q{arriter_o1.pir}  => qq(100000\n100000\n100000\n111111\n),
75     q{bench_newp.pasm} => qr/^\d+\.\d+\sseconds.\s\d+\.\d+\sloops\/sec\n
76         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
77         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
78         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
79         Copying\sa\stotal\sof\s\d+\sbytes\n
80         There\sare\s\d+\sactive\sPMC\sstructs\n
81         There\sare\s\d+\stotal\sPMC\sstructs\n
82         There\sare\s\d+\sactive\sBuffer\sstructs\n
83         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
84     q{fib.pir}     => qr/^fib\(28\)\s=\s317811\s\d+\.\d+s$/x,
85     q{freeze.pasm} => qr/^constr.time\s\d+\.\d+\n
86         freeze\stime\s\d+\.\d+\n
87         \s\sthaw\stime\s\d+\.\d+\n
88         Image\slen\s\d+\n
89         ResizablePMCArray\s100000\n$/x,
90     q{gc_alloc_new.pasm} => qr/^\d+\.\d+\sseconds\.\n
91         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
92         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
93         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
94         Copying\sa\stotal\sof\s\d+\sbytes\n
95         There\sare\s\d+\sactive\sBuffer\sstructs\n
96         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
97     q{gc_alloc_reuse.pasm} => qr/^\d+\.\d+\sseconds\.\n
98         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
99         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
100         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
101         Copying\sa\stotal\sof\s\d+\sbytes\n
102         There\sare\s\d+\sactive\sBuffer\sstructs\n
103         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
104     q{gc_generations.pasm} => qr/^\d+\.\d+\sseconds\.\n
105         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
106         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
107         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
108         Copying\sa\stotal\sof\s\d+\sbytes\n
109         There\sare\s\d+\sactive\sBuffer\sstructs\n
110         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
111     q{gc_header_new.pasm} => qr/^\d+\.\d+\sseconds\.\n
112         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
113         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
114         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
115         Copying\sa\stotal\sof\s\d+\sbytes\n
116         There\sare\s\d+\sactive\sBuffer\sstructs\n
117         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
118     q{gc_header_reuse.pasm} => qr/^\d+\.\d+\sseconds\.\n
119         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
120         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
121         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
122         Copying\sa\stotal\sof\s\d+\sbytes\n
123         There\sare\s\d+\sactive\sBuffer\sstructs\n
124         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
125     q{gc_waves_headers.pasm} => qr/^\d+\.\d+\sseconds\.\n
126         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
127         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
128         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
129         Copying\sa\stotal\sof\s\d+\sbytes\n
130         There\sare\s\d+\sactive\sBuffer\sstructs\n
131         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
132     q{gc_waves_sizeable_data.pasm} => qr/^\d+\.\d+\sseconds\.\n
133         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
134         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
135         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
136         Copying\sa\stotal\sof\s\d+\sbytes\n
137         There\sare\s\d+\sactive\sBuffer\sstructs\n
138         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
139     q{gc_waves_sizeable_headers.pasm} => qr/^\d+\.\d+\sseconds\.\n
140         A\stotal\sof\s\d+\sbytes\swere\sallocated\n
141         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
142         A\stotal\sof\s\d+\scollection\sruns\swere\smade\n
143         Copying\sa\stotal\sof\s\d+\sbytes\n
144         There\sare\s\d+\sactive\sBuffer\sstructs\n
145         There\sare\s\d+\stotal\sBuffer\sstructs\n$/x,
146 #omitted because they're slow and doesn't exercise anything novel
147 #    q{mops.pasm} => qr/^Iterations:\s\s\s\s10000000\n
148 #        Estimated\sops:\s20000000\n
149 #        done\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(mops_intval.pasm) => qr/^Iterations:\s\s\s\s100000000\n
153 #        Estimated\sops:\s200000000\n
154 #        Elapsed\stime:\s\s\d+\.\d+\n
155 #        M\sop\/s:\s\s\s\s\s\s\s\s\d+\.\d+\n$/x,
156     q{oo1.pasm}     => qq(10\n),
157     q{oo2.pasm}     => qq(10\n),
158     q{oo3.pasm}     => qq(10\n),
159     q{oo4.pasm}     => qq(500000\n),
160     q{oo5.pir}      => qq(10\n),
161     q{oo6.pir}      => qq(500000\n),
162     q{oofib.pir}    => qr/^fib\(24\)\s=\s46368\s\d+\.\d+s$/x,
163     q{overload.pir} => qq(42\n),
164     q{primes.pasm}  => qr/^N\sprimes\sup\sto\s5000\sis:\s669\n
165         last\sis:\s5001\n
166         Elapsed\stime:\s\d+\.\d+\n$/x,
167     q{primes2.pir} => qr/^N\sprimes\scalculated\sto\s500\sis\s96\n
168         last\sis:\s499\n$/x,
169     q{primes2_i.pir} => qr/^N\sprimes\scalculated\sto\s10000\s
170         is\s1230\nlast\sis:\s9973\n$/x,
171     q{primes_i.pasm} => qr/^N\sprimes\sup\sto\s10000\sis:\s1229\n
172         last\sis:\s9973\nElapsed\stime:\s\d+\.\d+\n$/x,
173     q{stress.pasm}     => qr/^A\stotal\sof\s\d+\sGC\sruns\s
174         were\smade\n$/x,
175     q{stress1.pasm} => qr/^\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
191         \d+\.\d+\n
192         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
193         \d+\.\d+\n
194         A\stotal\sof\s\d+\sGC\sruns\swere\smade\n$/x,
195     q{stress2.pasm} => qq(),
196     q{stress3.pasm} => qr/^A\stotal\sof\s\d+\sGC\sruns\swere\smade\n
197         \d+\sactive\sPMCs\n
198         \d+\stotal\s\sPMCs\n$/x,
199     q{vpm.pir} => qq(100000;\nl hackerjust another per\n)
202 # These scripts are known to be failing.
203 my %todo = ();
205 plan tests => scalar keys %outputs;
207 foreach ( sort keys %outputs ) {
208 SKIP: {
209         my $bench = Parrot::Test::slurp_file("examples/benchmarks/$_");
210         skip( "Could not slurp $_", 1 ) unless $bench;
212         my @todo = $todo{$_} ? ( todo => $todo{$_} ) : ();
214         if ( ref $outputs{$_} eq 'Regexp' ) {
215             example_output_like( "examples/benchmarks/$_", $outputs{$_}, @todo );
216         }
217         else {
218             example_output_is( "examples/benchmarks/$_", $outputs{$_}, @todo );
219         }
220     }
223 # Local Variables:
224 #   mode: cperl
225 #   cperl-indent-level: 4
226 #   fill-column: 100
227 # End:
228 # vim: expandtab shiftwidth=4: