-
Notifications
You must be signed in to change notification settings - Fork 14
/
main.cpp
51 lines (41 loc) · 1.53 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
#include <cstring>
#include <iostream>
#include <chrono>
#ifdef WITHGPERFTOOLS
#include <gperftools/profiler.h>
#endif
#include "Graph.h"
void Usage() {
cout << "Usage: [1]exe [2]graph-dir [3]similarity-threshold [4]density-threshold [5 optional]Output\n";
}
int main(int argc, char *argv[]) {
if (argc < 4) {
Usage();
} else {
// input
using namespace std::chrono;
auto io_start = high_resolution_clock::now();
auto *graph = new Graph(argv[1], argv[2], atoi(argv[3]));
auto io_end = high_resolution_clock::now();
cout << "\nTotal input cost:" << duration_cast<milliseconds>(io_end - io_start).count() << " ms\n";
// compute
auto start = high_resolution_clock::now();
#ifdef WITHGPERFTOOLS
cout << "with google perf start------------\n";
ProfilerStart("pscanProfile.log");
#endif
graph->pSCAN();
#ifdef WITHGPERFTOOLS
cout << "with google perf end--------------\n";
ProfilerStop();
#endif
auto end = high_resolution_clock::now();
cout << "Total time without IO:" << duration_cast<milliseconds>(end - start).count() << " ms\n";
// Output
io_start = high_resolution_clock::now();
if (argc >= 5 && strcmp(argv[4], "output") == 0) { graph->Output(argv[2], argv[3]); }
io_end = high_resolution_clock::now();
cout << "Total output cost:" << duration_cast<milliseconds>(io_end - io_start).count() << " ms\n\n";
}
return 0;
}