forked from slashdotted/cpp-consistent-hashing-algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.cpp
93 lines (82 loc) · 2.76 KB
/
Main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/**
* @author Roberto Vicario
*/
#include <iostream>
#include <yaml-cpp/yaml.h>
#include "Algorithms/anchor/AnchorEngine.hpp"
#include "Algorithms/dx/DxEngine.hpp"
#include "Algorithms/jump/JumpEngine.hpp"
#include "Algorithms/memento/MementoEngine.hpp"
#include "Algorithms/power/PowerEngine.hpp"
#include "Benchmarks/Routine.hpp"
#include "Handler/HandlerImpl.hpp"
using namespace std;
int main(int argc, char* argv[]) {
try {
/*
* Handling the terminal usage.
*/
string configName = (argc == 2) ? argv[1] : "default.yaml";
/*
* Loading the YAML file.
*/
string pathYaml = "../configs/" + configName;
YAML::Node yaml = YAML::LoadFile(pathYaml);
/*
* Creating the CSV file.
*/
auto pathCsv = yaml["common"]["output-folder"].as<string>();
pathCsv += "/results.csv";
pathCsv = pathCsv.substr(1);
HandlerImpl handler = HandlerImpl(pathCsv);
cout << "# [SYS] ----- ****************************" << endl;
cout << "# [SYS] ----- ***** STARTING ROUTINE *****" << endl;
cout << "# [SYS] ----- ****************************" << endl;
cout << "#" << endl;
/*
* Starting the benchmark routine.
*/
for (auto i : yaml["algorithms"]) {
auto algorithm = i["name"].as<string>();
if (algorithm == "anchor") {
/*
* ANCHOR
*/
// execute<AnchorEngine>("anchor", handler, yaml);
} else if (algorithm == "dx") {
/*
* DX
*/
execute<DxEngine>("dx", handler, yaml);
} else if (algorithm == "jump") {
/*
* JUMP
*/
// execute<JumpEngine>("jump", handler, yaml);
} else if (algorithm == "memento") {
/*
* MEMENTO
*/
// execute<MementoEngine<boost::unordered_flat_map>>("memento", handler, yaml);
} else if (algorithm == "power") {
/*
* POWER
*/
// execute<PowerEngine>("power", handler, yaml);
}
}
} catch (const YAML::Exception& e) {
cout << "# [ERR] ----- Exception: " << e.what() << endl;
return 1;
} catch (const exception& e) {
cout << "# [ERR] ----- Exception: " << e.what() << endl;
return 1;
}
/*
* Closing the benchmark routine.
*/
cout << "# [SYS] ----- *****************************" << endl;
cout << "# [SYS] ----- ***** ROUTINE COMPLETED *****" << endl;
cout << "# [SYS] ----- *****************************" << endl;
return 0;
}