-
Notifications
You must be signed in to change notification settings - Fork 1
/
Benchmark2.cpp
90 lines (68 loc) · 1.96 KB
/
Benchmark2.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
#include "RunMetadata.h"
#include "BloomFilter.h"
#include "LsmTree.h"
#include <iostream>
#include <fstream>
#include <unistd.h>
#include <random>
#include "GetTimeMs64.h"
using namespace std;
/* TODO have this use averages, or put it in the R */
int main(int argc, char *argv[]) {
if (argc < 6) {
cout << "Insufficient arguments." << endl;
cout << "Usage: './Benchmark runSize levelSize bloomSize file lines'" << endl;
return 1;
}
int runSize = stoi(argv[1]);
int levelSize = stoi(argv[2]);
int bloomSize = stoi(argv[3]);
string filename = argv[4];
int numLines = stoi(argv[5]);
ifstream file(filename.c_str());
string type, key, val;
char command;
int k, v;
int i = 0;
TierLsmTree *tree = new TierLsmTree(runSize, levelSize, bloomSize);
uint64 start = GetTimeMs64();
if (file.is_open()) {
while (i < numLines + numLines / 2) {
getline(file, type, ',');
command = type[0];
if ((type == "i") || (type == "u") || (type == "r")) {
getline(file, key, ',');
k = stoi(key);
getline(file, val);
v = stoi(val);
}
else {
getline(file, key);
k = stoi(key);
}
i++;
switch (command) {
case 'i':
tree->insert(k, v);
break;
case 'd':
tree->remove(k);
break;
case 'u':
tree->insert(k, v);
break;
case 'g':
tree->get(k);
break;
case 'r':
tree->getRange(k, v);
break;
}
}
file.close();
}
uint64 end = GetTimeMs64();
//Print total time elapsed
cout << end - start << endl;
return 0;
}