xapian-core  1.4.25
api_scalability.cc
Go to the documentation of this file.
1 
4 /* Copyright (C) 2008,2009,2011,2013,2015 Olly Betts
5  *
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.
10  *
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.
15  *
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
20  */
21 
22 #include <config.h>
23 
24 #include "api_scalability.h"
25 
26 #include "apitest.h"
27 #include "cputimer.h"
28 #include "scalability.h"
29 #include "str.h"
30 #include "testsuite.h"
31 #include "testutils.h"
32 
33 #include <xapian.h>
34 
35 using namespace std;
36 
37 static double
38 bigoaddvalue1_helper(unsigned num_values)
39 {
41 
42  Xapian::Document doc;
43  for (unsigned i = 0; i < num_values; ++i) {
44  doc.add_value(i, "moo");
45  }
46 
47  CPUTimer timer;
48 
49  db.add_document(doc);
50  db.commit();
51 
52  return timer.get_time();
53 }
54 
55 DEFINE_TESTCASE(bigoaddvalue1, writable) {
56  // O(n*n) is bad, but O(n*log(n)) is acceptable.
58 }
59 
60 static double
61 querypairwise1_helper(unsigned num_subqs)
62 {
63  CPUTimer timer;
64  for (int c = 0; c < 100; ++c) {
65  Xapian::Query q("xxx");
66  for (unsigned i = 0; i < num_subqs; ++i) {
67  q = Xapian::Query(q.OP_OR, q, Xapian::Query(str(i)));
68  }
69  }
70  return timer.get_time();
71 }
72 
73 // Check that composing queries pairwise is O(n).
74 DEFINE_TESTCASE(querypairwise1, !backend) {
76 }
Xapian::docid add_document(const Xapian::Document &document)
Add a new document to the database.
Definition: omdatabase.cc:902
void add_value(Xapian::valueno slot, const std::string &value)
Add a new value.
Definition: omdocument.cc:107
Test how an operation scales.
static double bigoaddvalue1_helper(unsigned num_values)
Xapian::WritableDatabase get_writable_database(const string &dbname)
Definition: apitest.cc:87
a generic test suite engine
STL namespace.
Convert types to std::string.
test functionality of the Xapian API
This class provides read/write access to a database.
Definition: database.h:789
Public interfaces for the Xapian library.
string str(int value)
Convert int to std::string.
Definition: str.cc:90
void commit()
Commit any pending modifications made to the database.
Definition: omdatabase.cc:857
DEFINE_TESTCASE(bigoaddvalue1, writable)
void test_scalability(double(*func)(unsigned), unsigned n, double threshold)
Definition: scalability.cc:29
#define O_N
Definition: scalability.h:32
double get_time() const
Return elapsed CPU time since object creation in seconds.
Definition: cputimer.h:34
Measure CPU time.
static double querypairwise1_helper(unsigned num_subqs)
Match documents which at least one subquery matches.
Definition: query.h:92
Xapian-specific test helper functions and macros.
#define O_N_LOG_N
Definition: scalability.h:33
Class representing a query.
Definition: query.h:46
A handle representing a document in a Xapian database.
Definition: document.h:61