-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.cpp
81 lines (65 loc) · 1.23 KB
/
test.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
// #include "stl.cpp"
//#include "linkedlist.cpp"
#include "heap.cpp"
#include <sstream>
#include <fstream>
#include <chrono>
using namespace chrono;
int main()
{
int i=0;
string name[881];
int priority[881];
int treatment[881];
ifstream file;
file.open("patientData2270.csv");
if(file.is_open())
{
string line;
while(getline(file,line, '\r'))
{
string words[3];
int j=0;
int start=0;
int count=0;
for(int k=0; k<(int)line.length(); k++)
{
if(line[k]!=',')
{
count++;
}
else
{
words[j]=line.substr(start, count);
start=k+1;
count=0;
j++;
}
}
words[j]=line.substr(start, count);
stringstream ss1(words[1]);
stringstream ss2(words[2]);
name[i]=words[0];
ss1>>priority[i];
ss2>>treatment[i];
i++;
}
}
// stl test;
//linkedlist test;
heap test;
auto start=system_clock::now();
for(int x=0; x<500; x++)
{
for(int j=1; j<801; j++)
{
test.enqueue(name[j], priority[j], treatment[j]);
}
//test.print();
test.dequeue();
}
auto end=system_clock::now();
auto duration=duration_cast<microseconds>(end-start);
cout<<"time use: "<<double(duration.count())*microseconds::period::num/500<<" microseconds."<<endl;
return 0;
}