/
file-bench.cpp
66 lines (55 loc) · 1.48 KB
/
file-bench.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
#include <iostream>
#include <fstream>
#include <unistd.h>
#include "FileBenchmark.hpp"
#include "SuccinctFile.hpp"
void print_usage(char *exec) {
fprintf(stderr, "Usage: %s [-m mode] [file]\n", exec);
}
int main(int argc, char **argv) {
if(argc < 2 || argc > 6) {
print_usage(argv[0]);
return -1;
}
int c;
uint32_t mode = 0;
std::string querypath = "";
while((c = getopt(argc, argv, "m:q:")) != -1) {
switch(c) {
case 'm':
mode = atoi(optarg);
break;
case 'q':
querypath = std::string(optarg);
break;
default:
mode = 0;
}
}
if(optind == argc) {
print_usage(argv[0]);
return -1;
}
std::string inputpath = std::string(argv[optind]);
if(mode == 0) {
SuccinctFile fd(inputpath);
// Serialize and save to file
std::ofstream s_out(inputpath + ".succinct");
fd.serialize();
s_out.close();
// Benchmark core and file functions
FileBenchmark s_bench(&fd, querypath);
s_bench.benchmark_core();
s_bench.benchmark_file();
} else if(mode == 1) {
SuccinctFile fd(inputpath, SuccinctMode::LOAD_IN_MEMORY);
// Benchmark core and file functions
FileBenchmark s_bench(&fd, querypath);
s_bench.benchmark_core();
s_bench.benchmark_file();
} else {
// Only modes 0, 1 supported for now
assert(0);
}
return 0;
}