-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
83 lines (73 loc) · 2.44 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
82
83
#include <iostream>
#include <string>
#include <map>
#include <iostream>
#include "tester.h"
using namespace std;
void TEST_CORRECT_NESS() {
cout<<"Sequential"<<endl;
Tester *mt = new Tester();
mt->sequential_add_test(1000);
int size_ = mt->skipList->size();
mt->sequential_erase_test(size_, 100);
delete mt;
cout<<endl;
for(int i=2; i<64;i=i*2){
Tester *mt = new Tester();
mt->concurrent_add_test(i, 1000);
int size_ = mt->skipList->size();
mt->concurrent_erase_test(size_,i,100);
delete mt;
cout<<endl;
}
for(int i=2; i<128;i=i*2){
Tester *mt = new Tester();
mt->concurrent_add_remove_test(i,i*2,10);
delete mt;
cout<<endl;
}
for(int i=1; i<128;i=i*2){
Tester *mt = new Tester();
mt->concurrent_add_remove_getvalue_test(i,i,i,10);
delete mt;
cout<<endl;
}
for(int i=1; i<128; i=i*2){
Tester *mt = new Tester();
mt->concurrent_add_remove_getentry_test(i,i,i,10);
delete mt;
cout<<endl;
}
}
// the drifting number of threads test with range 200,000 and 100,000 operations
void SKIP_LIST_TEST( int num_repeats, int work_load, int range, double ratio_get, double ratio_add, double ratio_remove, int debug) {
cout << "SKIP LIST PERFORMANCE TEST: " << endl;
cout << "\nget " << ratio_get << ", add " << ratio_add << ", remove " << ratio_remove << endl;
for( int i = 0; i < num_repeats; i++){
Tester *mt = new Tester();
// arguments:
// 1.the number of threads, 2.work load(operation), 3.range,
// 4.the ratio of get(), 5. the ratio of add(), 6. the ratio of remove(), 7. Debug
mt->performance_test( 10*(i+1), work_load, range, ratio_get, ratio_add, ratio_remove, debug);
delete mt;
}
cout << endl;
}
// the drifting number of threads test with range 200,000 and 100,000 operations
void RB_TREE_TEST( int num_repeats, int work_load, int range, double ratio_get, double ratio_add, double ratio_remove, int debug) {
cout << "RB TREE PERFORMANCE TEST: " << endl;
cout << "\nget " << ratio_get << ", add " << ratio_add << ", remove " << ratio_remove << endl;
for( int i = 0; i < num_repeats; i++){
Tester *rb = new Tester();
rb->rb_performance_test( 10*(i+1), work_load, range, ratio_get, ratio_add, ratio_remove, debug);
delete rb;
}
cout << endl;
}
int main()
{
int debug = 1;
TEST_CORRECT_NESS();
SKIP_LIST_TEST( 10, 100000, 200000, 0.9, 0.09, 0.01, debug);
RB_TREE_TEST( 10, 100000, 200000, 0.9, 0.09, 0.01, debug);
}