41 #ifdef HAVE_SYS_UTSNAME_H 42 # include <sys/utsname.h> 58 string::size_type p = 0;
59 while (p < str.size()) {
82 : testcase_started(
false),
83 indexing_started(
false),
84 searching_started(
false)
98 WORD WSAVerReq = MAKEWORD(1, 1);
101 if (WSAStartup(WSAVerReq, &WSAData) != 0) {
105 if (gethostname(buf,
sizeof(buf)) != 0) {
110 #elif defined HAVE_SYS_UTSNAME_H 111 struct utsname uname_buf;
112 if (uname(&uname_buf) != 0) {
113 uname_buf.nodename[0] =
'\0';
115 return uname_buf.nodename;
116 #elif defined HAVE_GETHOSTNAME 118 if (gethostname(buf,
sizeof(buf)) != 0) {
136 loadavg =
stdout_to_string(
"uptime 2>/dev/null | sed 's/.*: \\([0-9][0-9]*\\)/\\1/;s/, .*//'");
150 SYSTEM_INFO siSysInfo;
151 GetSystemInfo(&siSysInfo);
152 ncpus =
str(siSysInfo.dwNumberOfProcessors);
156 ncpus =
stdout_to_string(
"getconf _NPROCESSORS_ONLN 2>/dev/null | grep -v '[^0-9]'");
170 ncpus =
stdout_to_string(
"PATH=/usr/sbin:$PATH psrinfo 2>/dev/null | grep -c on-line");
194 ZeroMemory(&osvi,
sizeof(OSVERSIONINFO));
195 osvi.dwOSVersionInfoSize =
sizeof(OSVERSIONINFO);
199 # pragma warning(push) 200 # pragma warning(disable:4996) 204 # pragma warning(pop) 206 distro =
"Microsoft Windows v";
207 distro +=
str(osvi.dwMajorVersion);
209 distro +=
str(osvi.dwMinorVersion);
211 distro +=
str(osvi.dwBuildNumber);
228 commit_ref =
stdout_to_string(
"cd \"$srcdir\" && git log -n1 --abbrev-commit --format=%h");
239 out.open(logpath.c_str(), ios::out | ios::binary | ios::trunc);
240 if (!
out.is_open()) {
241 cerr <<
"Couldn't open output logfile '" << logpath <<
"'\n";
251 write(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<testrun>\n" 253 if (!hostname.empty())
254 write(
" <hostname>" + hostname +
"</hostname>\n");
255 if (!loadavg.empty())
256 write(
" <loadavg>" + loadavg +
"</loadavg>\n");
258 write(
" <ncpus>" + ncpus +
"</ncpus>\n");
260 write(
" <distro>" + distro +
"</distro>\n");
262 write(
" </machineinfo>\n");
266 write(
" <sourceinfo>\n");
267 if (!commit_ref.empty())
268 write(
" <commitref>" + commit_ref +
"</commitref>\n");
270 write(
" </sourceinfo>\n");
278 out.write(text.data(), text.size());
287 write(
"</testrun>\n");
294 const std::map<std::string, std::string> & params)
298 write(
" <indexrun dbname=\"" + dbname +
"\">\n <params>\n");
299 std::map<std::string, std::string>::const_iterator i;
300 for (i = params.begin(); i != params.end(); ++i) {
301 write(
" <param name=\"" + i->first +
"\">" +
escape_xml(i->second) +
"</param>\n");
303 i = params.find(
"flush_threshold");
304 if (i == params.end()) {
306 const char *p = getenv(
"XAPIAN_FLUSH_THRESHOLD");
308 flush_threshold = atoi(p);
309 if (flush_threshold == 0)
310 flush_threshold = 10000;
311 write(
" <param name=\"flush_threshold\">" +
314 write(
" </params>\n");
331 "<time>" +
str(elapsed) +
"</time>" 358 write(
" </indexrun>\n");
368 write(
" <searchrun>\n" 369 " <description>" +
escape_xml(description) +
"</description>\n");
387 "<time>" +
str(elapsed) +
"</time>" 390 "<size>" +
str(mset.
size()) +
"</size>" 403 write(
" </searchrun>\n");
412 write(
" <testcase name=\"" + testcase +
"\" backend=\"" +
423 write(
" </testcase>\n");
449 : repetitions_parsed(
false), repetitions(5)
452 &repetitions_string);
457 if (!repetitions_parsed) {
458 if (!repetitions_string.empty()) {
459 repetitions = atoi(repetitions_string.c_str());
461 repetitions_parsed =
true;
463 for (
int i = 0; i != repetitions; ++i) {
472 int main(
int argc,
char **argv)
474 if (!logger.
open(
"perflog.xml"))
static string get_loadavg()
Get the load average.
Xapian::doccount size() const
Return number of items in this MSet object.
Run multiple tests for different backends.
const std::string & get_dbtype() const
Get the database type currently in use.
static string get_ncpus()
Get the number of processors.
void searching_start(const std::string &description)
Log the start of a search run.
void repetition_begin(int num)
Start a repetition of the tests.
void search_start()
Log the start of a search.
Xapian::doccount get_matches_lower_bound() const
Lower bound on the total number of matching documents.
static string get_commit_ref()
Get the git commit for HEAD.
performance tests for Xapian.
run an external process and capture its output in a string.
void indexing_add()
Log the addition of a document in an indexing run.
a generic test suite engine
Class representing a list of search results.
bool indexing_unlogged_changes
Convert types to std::string.
long long get_total_physical_memory()
Determine how much physical memory there is.
Xapian::doccount indexing_addcount
static string escape_xml(const string &str)
void testcase_begin(const std::string &testcase)
Start a testcase.
static void add_command_line_option(const std::string &l, char s, std::string *arg)
Add a test-specific command line option.
const char * version_string()
Report the version string of the library which the program is linked with.
Xapian::doccount get_matches_upper_bound() const
Upper bound on the total number of matching documents.
int run_tests(int argc, char **argv)
Run all the tests.
Base class for backend handling in test harness.
Exception thrown if we encounter a read error.
string stdout_to_string(const string &cmd)
Run command cmd, capture its stdout, and return it as a std::string.
bool open(const std::string &logpath)
Open a file to log to.
BackendManager * backendmanager
backendmanager is global so that it can be accessed by individual tests.
string str(int value)
Convert int to std::string.
include <winsock2.h> but working around problems.
A test runner, which runs the tests (implemented by subclassing it) with a variety of backends...
Exception thrown if the program isn't found.
static string get_distro()
Get details of the OS and distribution.
void indexing_end()
Log the end of an indexing run.
include <windows.h> without all the bloat and damage.
static string get_hostname()
Get the hostname.
void close()
Flush and close the log file.
static Xapian::Query query(Xapian::Query::op op, const string &t1=string(), const string &t2=string(), const string &t3=string(), const string &t4=string(), const string &t5=string(), const string &t6=string(), const string &t7=string(), const string &t8=string(), const string &t9=string(), const string &t10=string())
int run() const
Run the tests with a particular backend.
Xapian::doccount get_matches_estimated() const
Estimate of the total number of matching documents.
double last_indexlog_timer
std::string get_description() const
Return a string describing this object.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
void repetition_end()
End a repetition of the tests.
double now()
Return the current time.
void search_end(const Xapian::Query &query, const Xapian::MSet &mset)
Log the completion of a search.
void indexing_log()
Write a log entry for the current indexing run.
Various handy helpers which std::string really should provide.
void searching_end()
Log the end of a search run.
<unistd.h>, but with compat.
void write(const std::string &text)
void testcase_end()
End a testcase.
Various assertion macros.
Functions for handling a time or time interval in a double.
Class representing a query.
determine how much free physical memory there is.
string repetitions_string
int main(int argc, char **argv)
void indexing_begin(const std::string &dbname, const std::map< std::string, std::string > ¶ms)
Log the start of an indexing run.