bfd22f229ffe774deedab7544c1b3eb3915bc3f9
[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 "TestDoubleAssign.h"
19 #include <turf/extra/Options.h>
20 #include <junction/details/Grampa.h> // for GrampaStats
21
22 static const ureg IterationsPerLog = 100;
23
24 int main(int argc, const char** argv) {
25     TestEnvironment env;
26
27     TestInsertSameKeys testInsertSameKeys(env);
28     TestInsertDifferentKeys testInsertDifferentKeys(env);
29     TestChurn testChurn(env);
30     TestDoubleAssign testDoubleAssign(env);
31     for (;;) {
32         for (ureg c = 0; c < IterationsPerLog; c++) {
33             testInsertSameKeys.run();
34             testInsertDifferentKeys.run();
35             testChurn.run();
36             testDoubleAssign.run();
37         }
38         turf::Trace::Instance.dumpStats();
39
40 #if JUNCTION_TRACK_GRAMPA_STATS
41         junction::DefaultQSBR.flush();
42         junction::details::GrampaStats& stats = junction::details::GrampaStats::Instance;
43         printf("---------------------------\n");
44         printf("numTables: %d/%d\n", (int) stats.numTables.current.load(turf::Relaxed),
45                (int) stats.numTables.total.load(turf::Relaxed));
46         printf("numTableMigrations: %d/%d\n", (int) stats.numTableMigrations.current.load(turf::Relaxed),
47                (int) stats.numTableMigrations.total.load(turf::Relaxed));
48         printf("numFlatTrees: %d/%d\n", (int) stats.numFlatTrees.current.load(turf::Relaxed),
49                (int) stats.numFlatTrees.total.load(turf::Relaxed));
50         printf("numFlatTreeMigrations: %d/%d\n", (int) stats.numFlatTreeMigrations.current.load(turf::Relaxed),
51                (int) stats.numFlatTreeMigrations.total.load(turf::Relaxed));
52 #endif
53     }
54
55     return 0;
56 }