Delete JunctionProjectDefs.cmake; simplify AddSample.cmake and move it to samples
[junction.git] / samples / MapCorrectnessTests / MapCorrectnessTests.cpp
1 /*------------------------------------------------------------------------
2   Junction: Concurrent data structures in C++
3   Copyright (c) 2016 Jeff Preshing
4
5   Distributed under the Simplified BSD License.
6   Original location: https://github.com/preshing/junction
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the LICENSE file for more information.
11 ------------------------------------------------------------------------*/
12
13 #include <junction/Core.h>
14 #include "TestEnvironment.h"
15 #include "TestInsertSameKeys.h"
16 #include "TestInsertDifferentKeys.h"
17 #include "TestChurn.h"
18 #include <turf/extra/Options.h>
19 #include <junction/details/Grampa.h>  // for GrampaStats
20
21 static const ureg IterationsPerLog = 100;
22
23 int main(int argc, const char** argv) {
24     TestEnvironment env;
25
26     TestInsertSameKeys testInsertSameKeys(env);
27     TestInsertDifferentKeys testInsertDifferentKeys(env);
28     TestChurn testChurn(env);
29     for (;;) {
30         for (ureg c = 0; c < IterationsPerLog; c++) {
31             testInsertSameKeys.run();
32             testInsertDifferentKeys.run();
33             testChurn.run();
34         }
35         turf::Trace::Instance.dumpStats();
36
37 #if JUNCTION_TRACK_GRAMPA_STATS
38         junction::DefaultQSBR.flush();
39         junction::details::GrampaStats& stats = junction::details::GrampaStats::Instance;
40         printf("---------------------------\n");
41         printf("numTables: %d/%d\n", (int) stats.numTables.current.load(turf::Relaxed), (int) stats.numTables.total.load(turf::Relaxed));
42         printf("numTableMigrations: %d/%d\n", (int) stats.numTableMigrations.current.load(turf::Relaxed), (int) stats.numTableMigrations.total.load(turf::Relaxed));
43         printf("numFlatTrees: %d/%d\n", (int) stats.numFlatTrees.current.load(turf::Relaxed), (int) stats.numFlatTrees.total.load(turf::Relaxed));
44         printf("numFlatTreeMigrations: %d/%d\n", (int) stats.numFlatTreeMigrations.current.load(turf::Relaxed), (int) stats.numFlatTreeMigrations.total.load(turf::Relaxed));
45 #endif
46     }
47
48     return 0;
49 }