-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnitTest.cpp
68 lines (57 loc) · 1014 Bytes
/
UnitTest.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
#include "ObjectPool.h"
#include "ConcurrentAlloc.h"
void func1()
{
for (size_t i = 0; i < 10; ++i)
{
ConcurrentAlloc(17);
}
}
void func2()
{
for (size_t i = 0; i < 20; ++i)
{
ConcurrentAlloc(5);
}
}
void TestThreads()
{
std::thread t1(func1);
std::thread t2(func2);
t1.join();
t2.join();
}
void TestSizeClass()
{
cout << SizeClass::Index(1035) << endl;
cout << SizeClass::Index(1025) << endl;
cout << SizeClass::Index(1024) << endl;
}
void TestConcurrentAlloc()
{
void* ptr0 = ConcurrentAlloc(5);
void* ptr1 = ConcurrentAlloc(8);
void* ptr2 = ConcurrentAlloc(8);
void* ptr3 = ConcurrentAlloc(8);
ConcurrentFree(ptr1);
ConcurrentFree(ptr2);
ConcurrentFree(ptr3);
}
void TestBigMemory()
{
void* ptr1 = ConcurrentAlloc(65 * 1024);
ConcurrentFree(ptr1);
void* ptr2 = ConcurrentAlloc(129 * 4 * 1024);
ConcurrentFree(ptr2);
}
//int main()
//{
// //TestBigMemory();
//
// //TestObjectPool();
// //TestThreads();
// //TestSizeClass();
// //TestConcurrentAlloc();
//
// return 0;
//}