-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.cpp
More file actions
83 lines (64 loc) · 1.9 KB
/
Copy pathtest.cpp
File metadata and controls
83 lines (64 loc) · 1.9 KB
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
#include "funkcijos.h"
#include "vector.h"
#include <vector>
int main() {
std::vector<int> stdVec;
myVector<int> myVec;
myVector<studentas> studentVec;
Timer stdVecTimer;
stdVecTimer.start();
int stdVecCount = 0;
for (int i = 0; i < 10000000; i++) {
stdVec.push_back(i);
if(stdVec.capacity() == stdVec.size())
{
stdVecCount++;
}
}
stdVecTimer.stop();
Timer myVecTimer;
myVecTimer.start();
for (int i = 0; i < 10000000; i++) {
myVec.push_back(i);
}
myVecTimer.stop();
Timer studentVecTimer;
studentVecTimer.start();
for(int i = 0; i < 10000000; i++)
{
studentVec.push_back(studentas("vardas", "i"));
}
studentVecTimer.stop();
std::vector<studentas> stdStud;
Timer studentai;
studentai.start();
for(int i = 0; i < 10000000; i++)
{
stdStud.push_back(studentas("vardas", "i"));
}
studentai.stop();
std::cout << "STDstudentVec uztruko " << studentai.elapsed() << " sec" << std::endl;
std::cout << "studentVec uztruko " << studentVecTimer.elapsed() << " sec" << std::endl;
std::cout << "std::vector uztruko " << stdVecTimer.elapsed() << " sec, pertvarkymu: " << stdVecCount << std::endl;
std::cout << "myVector uztruko " << myVecTimer.elapsed() << " sec, pertvarkymu: " << myVec.myVecCount << std::endl;
//testing 5 myVector functions against std::vector
stdVec.clear();
myVec.clear();
stdVec.emplace_back(1);
myVec.emplace_back(1);
for(int i = 0; i < stdVec.size(); i++)
{
std::cout << stdVec[i] << " ";
}
std::cout << std::endl;
myVec.print();
stdVec.resize(10);
myVec.resize(10);
for(int i = 0; i < stdVec.size(); i++)
{
std::cout << stdVec[i] << " ";
}
std::cout << std::endl;
myVec.print();
return 0;
}