forked from ahmed-shariff/StreamRarePatternMining
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
80 lines (62 loc) · 1.8 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
#include <iostream>
#include "SRPTree.h"
#include <ctime>
using namespace std;
int main()
{
SRPTree srpTree;
clock_t begin1, begin2, end1, end2 = clock();
int readCount = 0;
int timeCount = 0;
double time_spent = 0.0;
if (!srpTree.Initialize())
{
cout << "Initialization failed. Exiting...<<endl";
return 0;
}
begin1 = clock();
string sPerfFile = "perfFile20.txt";
ofstream fileperfwrite;
fileperfwrite.open(sPerfFile.c_str(), std::ofstream::out | std::ofstream::app);
cout << "Reading DB..." << endl;
fileperfwrite << "Reading DB..." << endl;
while (srpTree.ReadTransaction())
{
readCount++;
if (readCount == srpTree.GetWindowSize())
{
cout << "Mining..." << endl;
fileperfwrite << "Mining..." << endl;
begin2 = clock();
if (!timeCount)
{
time_spent = (double)(begin2 - begin1) / CLOCKS_PER_SEC;
}
else
{
time_spent = (double)(begin2 - end2) / CLOCKS_PER_SEC;
}
timeCount++;
cout << "Time spent in reading transactions (in seconds)" << time_spent << endl;
fileperfwrite << "Time spent in reading transactions (in seconds)" << time_spent << endl;
srpTree.Mine();
end2 = clock();
time_spent = (double)(end2 - begin2) / CLOCKS_PER_SEC;
cout << "Time spent in mining (in seconds)" << time_spent << endl;
cout << "Reading DB..." << endl;
fileperfwrite << "Time spent in mining (in seconds)" << time_spent << endl;
fileperfwrite << "Reading DB..." << endl;
readCount = 0;
}
}
end1 = clock();
srpTree.Finalize();
cout << "Mining Completed..." << endl;
fileperfwrite << "Mining Completed..." << endl;
time_spent = (double)(end1 - begin1)/CLOCKS_PER_SEC;
cout << "Time elapse = " << time_spent << "seconds";
fileperfwrite << "Time elapse = " << time_spent << "seconds";
fileperfwrite.close();
system("PAUSE");
return 0;
}