44 return unsigned(range * (rand() / (RAND_MAX + 1.0)));
52 return min + unsigned((max + 1 - min) * (rand() / (RAND_MAX + 1.0)));
60 return rand() / (RAND_MAX + 1.0);
69 gen_word(
unsigned int length,
unsigned int char_range)
72 result.reserve(length);
73 for (
unsigned int i = 0; i != length; ++i) {
74 char ch = char(
'a' +
rand_int(char_range));
84 std::string dbname(
"randomidx1");
87 unsigned int runsize = 100000;
88 unsigned int seed = 42;
91 unsigned int slots_used = 10;
92 double slot_probability = 0.7;
93 unsigned int slotval_minlen = 1;
94 unsigned int slotval_maxlen = 6;
96 unsigned int minterms = 100;
97 unsigned int maxterms = 1000;
98 unsigned int mintermlen = 1;
99 unsigned int maxtermlen = 10;
100 unsigned int termcharrange = 10;
104 std::map<std::string, std::string> params;
105 params[
"runsize"] =
str(runsize);
107 params[
"slots_used"] =
str(slots_used);
108 params[
"slot_probability"] =
str(slot_probability);
109 params[
"slotval_minlen"] =
str(slotval_minlen);
110 params[
"slotval_maxlen"] =
str(slotval_maxlen);
111 params[
"minterms"] =
str(minterms);
112 params[
"maxterms"] =
str(maxterms);
113 params[
"mintermlen"] =
str(mintermlen);
114 params[
"maxtermlen"] =
str(maxtermlen);
115 params[
"termcharrange"] =
str(termcharrange);
119 for (i = 0; i < runsize; ++i) {
123 unsigned int terms =
rand_int(minterms, maxterms);
124 for (
unsigned int j = 0; j < terms; ++j) {
125 unsigned int termlen =
rand_int(mintermlen, maxtermlen);
132 for (
unsigned int slot = 0; slot < slots_used; ++slot) {
133 if (
rand_01() < slot_probability) {
134 unsigned int len =
rand_int(slotval_minlen, slotval_maxlen);
Base class for backend handling in test harness.
virtual Xapian::WritableDatabase get_writable_database(const std::string &name, const std::string &file)
Get a writable database instance.
void indexing_begin(const std::string &dbname, const std::map< std::string, std::string > ¶ms)
Log the start of an indexing run.
void testcase_end()
End a testcase.
void indexing_end()
Log the end of an indexing run.
void testcase_begin(const std::string &testcase)
Start a testcase.
void indexing_add()
Log the addition of a document in an indexing run.
Class representing a document.
void set_data(std::string_view data)
Set the document data.
void add_term(std::string_view term, Xapian::termcount wdf_inc=1)
Add a term to this document.
void add_value(Xapian::valueno slot, std::string_view value)
Add a value to a slot in this document.
This class provides read/write access to a database.
void commit()
Commit pending modifications.
Xapian::docid add_document(const Xapian::Document &doc)
Add a document to the database.
string str(int value)
Convert int to std::string.
performance tests for Xapian.
static unsigned int rand_int(unsigned int range)
Generate a random integer from 0 to "range" - 1.
DEFINE_TESTCASE(randomidx1, writable &&!inmemory)
static double rand_01()
Generate a random double in range 0.0 <= v < 1.0.
static string gen_word(unsigned int length, unsigned int char_range)
Generate a "word", of the specified length.
Convert types to std::string.
BackendManager * backendmanager
backendmanager is global so that it can be accessed by individual tests.
Run multiple tests for different backends.
a generic test suite engine
Xapian-specific test helper functions and macros.
Public interfaces for the Xapian library.