00001 00004 /* Copyright 2008 Lemur Consulting Ltd 00005 * Copyright 2010 Olly Betts 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License as 00009 * published by the Free Software Foundation; either version 2 of the 00010 * License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 00020 * USA 00021 */ 00022 00023 #ifndef XAPIAN_INCLUDED_PERFTEST_H 00024 #define XAPIAN_INCLUDED_PERFTEST_H 00025 00026 #include <xapian.h> 00027 00028 #include <fstream> 00029 #include <map> 00030 #include <string> 00031 00032 class PerfTestLogger { 00033 std::ofstream out; 00034 00035 int repetition_number; 00036 00037 bool testcase_started; 00038 00039 bool indexing_started; 00040 Xapian::doccount indexing_addcount; 00041 bool indexing_unlogged_changes; 00042 double indexing_timer; 00043 double last_indexlog_timer; 00044 00045 bool searching_started; 00046 double searching_timer; 00047 00050 void indexing_log(); 00051 00052 void write(const std::string & text); 00053 00054 public: 00055 PerfTestLogger(); 00056 ~PerfTestLogger(); 00057 00062 bool open(const std::string & logpath); 00063 00066 void close(); 00067 00070 void indexing_begin(const std::string & dbname, 00071 const std::map<std::string, std::string> & params); 00072 00075 void indexing_add(); 00076 00079 void indexing_end(); 00080 00083 void searching_start(const std::string & description); 00084 00087 void search_start(); 00088 00091 void search_end(const Xapian::Query & query, 00092 const Xapian::MSet & mset); 00093 00096 void searching_end(); 00097 00100 void testcase_begin(const std::string & testcase); 00101 00104 void testcase_end(); 00105 00108 void repetition_begin(int num); 00109 00112 void repetition_end(); 00113 }; 00114 00115 extern PerfTestLogger logger; 00116 00117 #endif // XAPIAN_INCLUDED_PERFTEST_H