1 /** @file api_scalability.cc
2 * @brief Tests of scalability.
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
24 #include "api_scalability.h"
28 #include "scalability.h"
30 #include "testsuite.h"
31 #include "testutils.h"
38 bigoaddvalue1_helper(unsigned num_values
)
40 Xapian::WritableDatabase db
= get_writable_database();
43 for (unsigned i
= 0; i
< num_values
; ++i
) {
44 doc
.add_value(i
, "moo");
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
);
62 querypairwise1_helper(unsigned num_subqs
)
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
);