Document xapian-compact --blocksize takes an argument
[xapian.git] / xapian-core / tests / api_scalability.cc
blobb7fdd958e18185fa27f61114dda556339909983f
1 /** @file api_scalability.cc
2 * @brief Tests of scalability.
3 */
4 /* Copyright (C) 2008,2009,2011,2013,2015 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
19 * USA
22 #include <config.h>
24 #include "api_scalability.h"
26 #include "apitest.h"
27 #include "cputimer.h"
28 #include "scalability.h"
29 #include "str.h"
30 #include "testsuite.h"
31 #include "testutils.h"
33 #include <xapian.h>
35 using namespace std;
37 static double
38 bigoaddvalue1_helper(unsigned num_values)
40 Xapian::WritableDatabase db = get_writable_database();
42 Xapian::Document doc;
43 for (unsigned i = 0; i < num_values; ++i) {
44 doc.add_value(i, "moo");
47 CPUTimer timer;
49 db.add_document(doc);
50 db.commit();
52 return timer.get_time();
55 DEFINE_TESTCASE(bigoaddvalue1, writable) {
56 // O(n*n) is bad, but O(n*log(n)) is acceptable.
57 test_scalability(bigoaddvalue1_helper, 5000, O_N_LOG_N);
58 return true;
61 static double
62 querypairwise1_helper(unsigned num_subqs)
64 CPUTimer timer;
65 for (int c = 0; c < 100; ++c) {
66 Xapian::Query q("xxx");
67 for (unsigned i = 0; i < num_subqs; ++i) {
68 q = Xapian::Query(q.OP_OR, q, Xapian::Query(str(i)));
71 return timer.get_time();
74 // Check that composing queries pairwise is O(n).
75 DEFINE_TESTCASE(querypairwise1, !backend) {
76 test_scalability(querypairwise1_helper, 50, O_N);
77 return true;