forked from alwei/MemoryMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
60 lines (54 loc) · 1.05 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
#include "MemoryMaster.h"
#include <boost/progress.hpp>
// #define new new(__FILE__, __LINE__)
class Base {
int a, b;
float c, d;
};
class Test : public Base {
public:
Test() {}
~Test() {}
};
class TestAppendMemoryPool :
public Base,
public MemoryPool::AppendMemoryPool<Test, 10000>
{
public:
TestAppendMemoryPool() {}
~TestAppendMemoryPool() {}
};
int main() {
{
boost::progress_timer t;
Test* ptr;
for (int j = 0; j < 10000; ++j) {
for (int i = 0; i < 10000; ++i) {
ptr = new Test;
delete ptr;
}
}
}
{
boost::progress_timer t;
TestAppendMemoryPool::init();
TestAppendMemoryPool* ptr;
for (int j = 0; j < 10000; ++j) {
for (int i = 0; i < 10000; ++i) {
ptr = new TestAppendMemoryPool;
delete ptr;
}
}
}
{
boost::progress_timer t;
MemoryPool::MakeMemoryPool<Test, 10000> mp;
Test* ptr;
for (int j = 0; j < 10000; ++j) {
for (int i = 0; i < 10000; ++i) {
ptr = mp.poolNew();
mp.poolDelete(ptr);
}
}
}
}