-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench.cpp
67 lines (51 loc) · 1.45 KB
/
bench.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
#include <set>
#include <cstdlib>
#include <iostream>
#include <ctime>
#include "rbt.h"
using namespace std;
const int tc = 1e6;
int main(){
ios_base::sync_with_stdio(0);
srand(time(nullptr));
multiset <int> st;
clock_t begin = clock();
for(int i=0; i<tc; i++){
st.insert(i);
}
clock_t end = clock();
cout << "CPP SET INSERT TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
rb <int> rbt;
begin = clock();
for(int i=0; i<tc; i++){
rbt.insert(i);
}
end = clock();
cout << "RBT INSERT TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
begin = clock();
for(int i=0; i<tc; i++){
st.find(i);
}
end = clock();
cout << "CPP SET FIND TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
begin = clock();
for(int i=0; i<tc; i++){
rbt.find(i);
}
end = clock();
cout << "RBT FIND TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
begin = clock();
for(int i=0; i<tc; i++){
st.erase(i);
}
end = clock();
cout << "CPP SET ERASE TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
cout << *rbt.find(123) << endl;
begin = clock();
for(int i=0; i<tc; i++){
rbt.remove(i);
}
end = clock();
cout << "RBT ERASE TIME OVER " << tc << " CASES: " << endl << fixed << double(end-begin) / CLOCKS_PER_SEC << endl;
return 0;
}