-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTest.h
More file actions
64 lines (53 loc) · 1.49 KB
/
Test.h
File metadata and controls
64 lines (53 loc) · 1.49 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
//
// Created by webve on 16.12.2017.
//
#ifndef TEST
#pragma once
#include <ctime>
#include "Tree.h"
class Test {
typedef int KeyType;
typedef int DataType;
int readings_Add;
int readings_Remove;
int readings_Find;
public:
static void test_randomTree(int n){
// srand((time(0)));
Tree<KeyType ,DataType> tree;
KeyType arrayKeys[n];
DataType data = (DataType)(rand() % (n*100));
std::cout << "Labor intensity: " <<std::endl;
for (int i = 0; i < n ; i++) {
KeyType key = (KeyType )(rand() % (n*100));
tree.put(key,data);
}
//Add
double avgAdd = 0;
for (int i = 0; i < n ; i++) {
KeyType key = (KeyType )(rand() % (n*100));
tree.put(key,data);
arrayKeys[i] = key;
avgAdd += tree.readings;
}
avgAdd /= (double)n;
std::cout << "Add: " << avgAdd << std::endl;
//Find
double avgFind = 0;
for (int i = 0; i < n; i++) {
tree.get(arrayKeys[i]);
avgFind += tree.readings;
}
avgFind /= (double)n;
std::cout << "Find: " << avgFind << std::endl;
//Remove
double avgRemove = tree.readings / (double)n;
for (int i = 0; i < n ; i++) {
tree.remove(arrayKeys[i]);
avgRemove += tree.readings;
}
avgRemove /= (double)n;
std::cout << "Remove: " << avgRemove << std::endl;
}
};
#endif //TEST