BAM
Abstract Machine for Bottom-Up Evaluation with the Push Method
test.h
Go to the documentation of this file.
1 // ============================================================================
2 // Project: Deductive Database
3 // Filename: test.h
4 // Purpose: List of all Tests/Benchmarks
5 // Last Change: 11.08.2017
6 // Language: C++
7 // EMail: brass@informatik.uni-halle.de
8 // WWW: http://www.informatik.uni-halle.de/~brass/
9 // Address: Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
10 // Copyright: (c) 2016-2017 by Stefan Brass
11 // License: See file "LICENSE" for copying conditions.
12 // Note: There is no warranty at all - this code may contain bugs.
13 // ============================================================================
14 
15 
28 //=============================================================================
29 // Include File Frame:
30 //=============================================================================
31 
32 #ifndef TEST_INCLUDED
33 #define TEST_INCLUDED
34 
35 //=============================================================================
36 // Used Types and Macros:
37 //=============================================================================
38 
39 #ifndef VER_INCLUDED
40 #include "../base/ver.h"
41 #endif
42 
43 #ifndef STR_INCLUDED
44 #include "../base/str.h"
45 #endif
46 
47 #ifndef CHECK_INCLUDED
48 #include "../base/check.h"
49 #endif
50 
51 #ifndef REL_INCLUDED
52 #include "../rel/rel.h"
53 #endif
54 
55 #ifndef RTEST_INCLUDED
56 #include "rtest.h"
57 #endif
58 
59 #ifndef BENCH_INCLUDED
60 #include "bench.h"
61 #endif
62 
63 //=============================================================================
64 // Private Constants:
65 //=============================================================================
66 
67 //-----------------------------------------------------------------------------
68 // TEST_MAGIC: Magic number (identifies objects of this class).
69 //-----------------------------------------------------------------------------
70 
71 static const long TEST_MAGIC = 0x5445530AL; // 'TES\n'
72 
73 
74 //=============================================================================
75 // Class Containing All Tests / Benchmarks:
76 //=============================================================================
77 
78 class test_c {
79  public:
80 
81 //-----------------------------------------------------------------------------
82 // Constructor, Destructor:
83 //-----------------------------------------------------------------------------
84 
85  // Constructor:
86  test_c(str_t test_id, bool (*test_fun)(test_c* test),
87  int test_arg, str_t test_name);
88 
89  // Destructor:
90  ~test_c();
91 
92 //-----------------------------------------------------------------------------
93 // (Object) Methods:
94 //-----------------------------------------------------------------------------
95 
96  // id: Return ID of this test (short name).
97  str_t id() {
98  // Check this object:
99  CHECK_VALID("test_c::id");
100 
101  // Return ID attribute value:
102  return Id;
103  }
104 
105  // run: Execute this test.
106  bool run();
107 
108 //-----------------------------------------------------------------------------
109 // Static Methods:
110 //-----------------------------------------------------------------------------
111 
112  // get_test: Get test with a given ID.
113  static test_c* get_test(str_t test_id);
114 
115  // print_list: Print list of all tests.
116  static void print_list();
117 
118 //-----------------------------------------------------------------------------
119 // Debugging Support:
120 //-----------------------------------------------------------------------------
121 
122 #if VER_DEBUG
123  public:
124  // Integrity check:
125  str_t check() const;
126 
127  private:
128  // Magic number (identifies objects of this class for debugging).
129  long Magic; // Must be "TEST_MAGIC".
130 #endif
131 
132 #if VER_DUMP
133  public:
134  // Display data structure:
135  void dump(str_t headline = STR_NULL) const;
136 #endif
137 
138 //-----------------------------------------------------------------------------
139 // Copy-constructor and assignment operator are not supported for this class:
140 //-----------------------------------------------------------------------------
141 
142  private:
143 
144  test_c(const test_c& obj); // Not implemented
145  test_c& operator=(const test_c& obj); // Not implemented
146 
147 //-----------------------------------------------------------------------------
148 // Private Object Members:
149 //-----------------------------------------------------------------------------
150 
151  private:
152 
153  // Id of Test/Benchmark (short name):
154  str_t Id;
155 
156  // Integer Argument of Benchmark (0 if not used):
157  int Arg;
158 
159  // Test/Benchmark Function:
160  bool (*Fun)(test_c* test);
161 
162  // Name of the Test/Benchmark (longer name, description):
163  str_t Name;
164 
165  // Test was executed:
166  bool Done;
167 
168  // Test was successful:
169  bool Ok;
170 
171  // Something strange happened (e.g. very different cpu/realtime):
172  bool Warn;
173 
174  // Overall Runtime (Larger of Wallclock and CPU-Time):
175  long TotalTime;
176 
177  // If Standard Benchmark: Time for Loading Data.
178  long LoadTime;
179 
180  // If Standard Benchmark: Time for Bottom-Up Evaluation.
181  long EvalTime;
182 
183 //-----------------------------------------------------------------------------
184 // Private Methods - Auxiliary Functions for Executing the tests:
185 //-----------------------------------------------------------------------------
186 
187  private:
188 
189  // run_bench: Run a Benchmark.
190  bool run_bench(bench_t bench);
191 
192  // run_bench_static: Run a Benchmark defined as a static method.
193  bool run_bench_static(str_t name,
194  long (*run)(str_t file, perf_t timer_load, perf_t timer_eval),
195  str_t file_name, long expected_result);
196 
197  // run_rtest: Run a test of a data structure for storing relations.
198  bool run_rtest(rtest_t rtest, rel_t rel);
199 
200  // Function to call if argument is not used:
201  void arg_unused();
202 
203  // mem_statistics: Print memory pool statistics.
204  void mem_statistics(str_t headline);
205 
206  // test_failed: An error occurred during the test.
207  void test_failed(str_t msg);
208 
209  // wrong_result: A function called in the test returned a wrong result.
210  void wrong_result(str_t fun, long result, long expected_result);
211 
212  // rtest_failed: An error occurred during insertion/lookup of a tuple.
213  void rtest_failed(str_t msg, int tuple_no, int arity, int c1, int c2);
214 
215  // max_time: Return the larger of realtime+cputime, check plausibility.
216  long max_time(long realtime, long cputime);
217 
218 //-----------------------------------------------------------------------------
219 // Private Static Methods - These are the Test Functions:
220 //-----------------------------------------------------------------------------
221 
222  private:
223 
224  //---------------------------------------------------------------------
225  // Tests of Data Structures for Storing Relations:
226  //---------------------------------------------------------------------
227 
228  // Test set with one int column, implemented as dynamic hash table:
229  static bool set_1d(test_c* test);
230 
231  // Test set with one int column, implemented as extendible hash table:
232  static bool set_1e(test_c* test);
233 
234  // Test set with one int column, implemented using C++11 standard lib:
235  static bool set_1s(test_c* test);
236 
237  // Test set with two int columns, implemented as dynamic hash table:
238  static bool set_2d(test_c* test);
239 
240  // Test set with two int columns, implemented as extendible hash table:
241  static bool set_2e(test_c* test);
242 
243  // Test set with two int columns, implemented using C++11 standard lib:
244  static bool set_2s(test_c* test);
245 
246  //---------------------------------------------------------------------
247  // Benchmarks for Bottom-Up Evaluation:
248  //---------------------------------------------------------------------
249 
250  // DBLP benchmark (different implementations):
251  static bool bench_dblp_1(test_c* test);
252  static bool bench_dblp_2(test_c* test);
253  static bool bench_dblp_3(test_c* test);
254 
255  // Join 1 benchmark with query a(X,Y):
256  static bool bench_j1axy_1(test_c* test);
257  static bool bench_j1axy_2(test_c* test);
258  static bool bench_j1axy_3(test_c* test);
259  static bool bench_j1axy_4(test_c* test);
260  static bool bench_j1axy_5(test_c* test);
261  static bool bench_j1axy_6(test_c* test);
262  static bool bench_j1axy_7(test_c* test);
263  static bool bench_j1axy_8(test_c* test);
264  static bool bench_j1axy_9(test_c* test);
265 
266  // Transitive closure benchmark with query tc(X,Y), i.e. binding "ff":
267  static bool bench_tcff_1(test_c* test);
268  static bool bench_tcff_2(test_c* test);
269  static bool bench_tcff_3(test_c* test);
270  static bool bench_tcff_4(test_c* test);
271  static bool bench_tcff_5(test_c* test);
272 
273  // Transitive closure benchmark with query tc(1,X), i.e. binding "bf":
274  static bool bench_tcbf_1(test_c* test);
275  static bool bench_tcbf_2(test_c* test);
276  static bool bench_tcbf_4(test_c* test);
277 
278  // The "Wine Ontology" benchmark:
279  static bool bench_wine(test_c* test);
280 
281 //-----------------------------------------------------------------------------
282 // Data Load Tests (Partial Benchmarks):
283 //-----------------------------------------------------------------------------
284 
285  // Load DBLP data file:
286  static bool load_dblp(test_c* test);
287 
288  // Load transitive closure data file:
289  static bool load_tc(test_c* test);
290 
291  // Load transitive closure data file, new version with general loader:
292  static bool load_tc_gen(test_c* test);
293 
294 //-----------------------------------------------------------------------------
295 // Dummy Test Function:
296 //-----------------------------------------------------------------------------
297 
298  static bool end_marker(test_c* test);
299 
300 //-----------------------------------------------------------------------------
301 // Private Static Variables:
302 //-----------------------------------------------------------------------------
303 
304  private:
305 
306  // List of all tests:
307  static test_c Tests[];
308 
309 //=============================================================================
310 // End of Class:
311 //=============================================================================
312 
313 };
314 
315 //-----------------------------------------------------------------------------
316 // Define pointer type:
317 //-----------------------------------------------------------------------------
318 
319 typedef test_c *test_t;
320 
321 //-----------------------------------------------------------------------------
322 // Define null pointer:
323 //-----------------------------------------------------------------------------
324 
325 #define TEST_NULL (static_cast<test_t>(0))
326 
327 //=============================================================================
328 // End of Include File:
329 //=============================================================================
330 
331 #endif
332 
Abstract Superclass of Standard Benchmarks with load() and eval()
Abstract superclass for Standard Benchmarks with load() and eval() Methods.
Definition: bench.h:67
Superclass for Standard Tests of Relation-like Data Structures.
Abstract superclass for Standard Tests/Benchmarks of relation-like data structures with insert() and ...
Definition: rtest.h:81
Definition: rel.h:72
Definition: perf.h:69
#define CHECK_VALID(EX)
Definition: check.h:85
const char * str_t
Definition: str.h:41
#define STR_NULL
Definition: str.h:52
Definition: test.h:78