2 * @brief Test how an operation scales.
4 /* Copyright (C) 2009 Olly Betts
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "scalability.h"
26 #include "testsuite.h"
29 test_scalability(double (*func
)(unsigned), unsigned n
, double threshold
)
32 // Increase the number of tests until we take a reliably measurable amount
36 tout
<< "Test with " << n
<< " repetitions took " << time1
<< " secs\n";
37 unsigned n_new
= n
* 10;
39 SKIP_TEST("Can't count enough repetitions to be able to time test");
41 } while (time1
<= 0.001);
43 double time10
= func(n
);
44 tout
<< "Test with " << n
<< " repetitions took " << time10
<< " secs\n";
46 TEST_REL(time10
,<,time1
* threshold
);