This repository has been archived by the owner on Feb 24, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
168 lines (125 loc) · 3.13 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
#include <iostream>
#include "SensorData.h" // for test purpose only
#include "BaseSensorBuffer.h" // for test purpose only
#include "Optimized_MapListSensorBuffer.h"
#include "VectorSensorBuffer.h"
#include "ListSensorBuffer.h"
#include "MapListSensorBuffer.h"
#include <string>
#include <fstream>
#include <time.h>
int number_of_files =12; // MODIFY ME !
using namespace std;
void test_sensor()
{
SensorData<int> A(1,2);
SensorData<int> B(A);
SensorData<int> C(2,-5);
C = A;
}
void test_buffer()
{
BaseSensorBuffer<int> bsb;
bsb.read("sensors.txt","outBaseInt.txt");
}
void test_vector()
{
VectorSensorBuffer<int> vsb;
vsb.read("sensors.txt","outVectorInt.txt");
}
void test_list()
{
ListSensorBuffer<int> lsb;
lsb.read("sensors.txt","outListInt.txt");
}
void test_Maplist()
{
MapListSensorBuffer<int> mlsb;
mlsb.read("sensors.txt","outMapListInt.txt");
}
void test_asymptotic()
{
int i = 0;
double time_taken ;
clock_t t;
VectorSensorBuffer<float> vsb;
ListSensorBuffer<float> lsb;
MapListSensorBuffer<float> mlsb;
Optimized_MapListSensorBuffer<float> omsb;
string inputfilename ="largedata.txt";
t = clock();
vsb.read(inputfilename.c_str(),"outVector.txt");
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC; // in seconds
cout << " vector processing took : "<<time_taken <<" s"<<endl;
t = clock();
lsb.read(inputfilename.c_str(),"outList.txt");
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC;
cout << " list processing took : "<<time_taken <<" s"<<endl;
t = clock();
mlsb.read(inputfilename.c_str(),"outMapList.txt");
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC;
cout << " Map of lists processing took : "<<time_taken <<" s"<<endl;
t = clock();
omsb.read(inputfilename.c_str(),"outMapList.txt");
t = clock() - t;
time_taken = ((double)t)/CLOCKS_PER_SEC;
cout << " Otimized Map of lists processing took : "<<time_taken <<" s"<<endl;
}
void timing_test()
{
ifstream inputfile;
ofstream out;
out.open("timing.txt");
string filename;
string a("largedata");
string b(".txt");
clock_t clk;
double time;
for (int i = 0; i < number_of_files; ++i)
{
filename = a + to_string(i) + b;
inputfile.open(filename.c_str());
out << i << " ";
VectorSensorBuffer<float> V;
ListSensorBuffer<float> L;
MapListSensorBuffer<float> M;
clk = clock();
V.read(filename.c_str(),"outVector.txt");
clk = clock() - clk;
time = (double)clk / CLOCKS_PER_SEC;
out << time << " ";
clk = clock();
L.read(filename.c_str(),"outList.txt");
clk = clock() - clk;
time = (double)clk / CLOCKS_PER_SEC;
out << time << " ";
clk = clock();
M.read(filename.c_str(),"outMapList.txt");
clk = clock() - clk;
time = (double)clk / CLOCKS_PER_SEC;
out << time << endl;
inputfile.close();
}
out.close();
}
void test_opt()
{
Optimized_MapListSensorBuffer <float> Opt;
Opt.read("sensors.txt","outOpt.txt");
}
int main(int argc, char const *argv[])
{
//test_sensor();
//test_buffer();
//test_vector();
//test_list();
//test_Maplist();
test_asymptotic();
//timing_test();
//test_opt();
cout <<"programmed executed with no errors"<<endl;
return 0;
}