SpiecsEngine
 
Loading...
Searching...
No Matches
MemoryPool_test.h
Go to the documentation of this file.
1/**
2* @file MemoryPool_test.h.
3* @brief The MemoryPool_test Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include <gmock/gmock.h>
9#include <Core/Memory/MemoryPool.h>
10#include "Instrumentor.h"
11
12namespace SpicesTest {
13
15 {
16 public:
17
19 : m_Tuple{ 1, 2.0f, nullptr }
20 {}
21
24
25 std::tuple<int, float, void*> m_Tuple;
26 };
27
29 {
30 public:
31
32 MemoryPoolTest2() = default;
35
36 static constexpr size_t x = 1024;
37 static constexpr size_t y = 1024;
38 std::array<std::array<int, x>, y> datas; // 4M
39 };
40
41 /**
42 * @brief The interface is inherited from testing::Test.
43 * Registry on Initialize.
44 */
46 {
47 protected:
48
49 /**
50 * @brief The interface is inherited from testing::Test.
51 * Registry on Initialize.
52 */
53 void SetUp() override {}
54
55 /**
56 * @brief The interface is inherited from testing::Test.
57 * Call before Destructor.
58 */
60
61 /**
62 * @brief Iter counts.
63 */
64 static constexpr size_t n = 10000;
65
66 /**
67 * @brief Iter counts 2.
68 */
69 static constexpr size_t n2 = 256;
70 };
71
72 /**
73 * @brief Testing Spices::MemoryPool::PointerSpace.
74 */
76
78
79 uint64_t a = 1;
80 uint64_t b = 10;
81 uint64_t c = 100;
82
84 uint64_t* d0 = reinterpret_cast<uint64_t*>(a);
85 EXPECT_EQ(d0, &b);
86 EXPECT_EQ(*d0, b);
87
89 uint64_t* d1 = reinterpret_cast<uint64_t*>(a);
90 EXPECT_EQ(d1, &c);
91 EXPECT_EQ(*d1, c);
92
94 uint64_t* d2 = reinterpret_cast<uint64_t*>(a);
95 EXPECT_EQ(d2, nullptr);
96 }
97
98 /**
99 * @brief Testing Spices::MemoryPool::AlignUp.
100 */
102
104
105 EXPECT_EQ(Spices::MemoryPool::AlignUp(1), 8);
106 EXPECT_EQ(Spices::MemoryPool::AlignUp(127), 128);
107
108 EXPECT_EQ(Spices::MemoryPool::AlignUp(129), 144);
109 EXPECT_EQ(Spices::MemoryPool::AlignUp(1023), 1024);
110
111 EXPECT_EQ(Spices::MemoryPool::AlignUp(1025), 1152);
112 EXPECT_EQ(Spices::MemoryPool::AlignUp(8 * 1024 - 1), 8 * 1024);
113
114 EXPECT_EQ(Spices::MemoryPool::AlignUp(8 * 1024 + 1), 9 * 1024);
115 EXPECT_EQ(Spices::MemoryPool::AlignUp(64 * 1024 - 1), 64 * 1024);
116
117 EXPECT_EQ(Spices::MemoryPool::AlignUp(64 * 1024 + 1), 72 * 1024);
118 EXPECT_EQ(Spices::MemoryPool::AlignUp(256 * 1024 - 1), 256 * 1024);
119
120 EXPECT_EQ(Spices::MemoryPool::AlignUp(257 * 1024 + 1), 264 * 1024);
121
122 EXPECT_EQ(Spices::MemoryPool::AlignUp(1024 * 1024 + 1), 1032 * 1024);
123 }
124
125 /**
126 * @brief Testing Spices::MemoryPool::Index.
127 */
129
131
132 EXPECT_EQ(Spices::MemoryPool::Index(1), 0);
133 EXPECT_EQ(Spices::MemoryPool::Index(16), 1);
134 EXPECT_EQ(Spices::MemoryPool::Index(128), 15);
135 EXPECT_EQ(Spices::MemoryPool::Index(256 * 1024), 207);
136 }
137
138 /**
139 * @brief Testing Spices::MemoryPool::Alloc/Free.
140 */
142
144
145 std::array<MemoryPoolTest*, n> objects;
146 for (size_t i = 0; i < n; i++)
147 {
148 MemoryPoolTest* a = new(Spices::MemoryPool::Alloc(sizeof(MemoryPoolTest)))MemoryPoolTest;
149
150 EXPECT_EQ(std::get<0>(a->m_Tuple), 1.0f);
151 EXPECT_EQ(std::get<1>(a->m_Tuple), 2);
152 EXPECT_EQ(std::get<2>(a->m_Tuple), nullptr);
153
154 objects[i] = a;
155 }
156
157 std::array<MemoryPoolTest2*, n2> object2s;
158 for (size_t i = 0; i < n2; i++)
159 {
160 MemoryPoolTest2* b = new(Spices::MemoryPool::Alloc(sizeof(MemoryPoolTest2)))MemoryPoolTest2;
161
162 object2s[i] = b;
163 }
164
165 for (size_t i = 0; i < n; i++)
166 {
167 Spices::MemoryPool::Free(objects[i]);
168 }
169
170 for (size_t i = 0; i < n2; i++)
171 {
172 Spices::MemoryPool::Free(object2s[i]);
173 }
174 }
175
176 /**
177 * @brief Testing Spices::MemoryPool Performance.
178 */
180
182
183 static constexpr int nThread = 1;
184 static constexpr int nCount = 500000;
185
186 {
187 SPICESTEST_PROFILE_SCOPE("new / delete");
188
189 std::vector<std::thread> threads;
190 for (int i = 0; i < nThread; i++)
191 {
192 std::thread t1([&]() {
193 std::vector<MemoryPoolTest*> objects;
194 objects.resize(nCount);
195
196 for (int j = 0; j < nCount; j++)
197 {
199
200 objects[j] = std::move(p);
201 }
202
203 for (int j = 0; j < nCount; j++)
204 {
205 MemoryPoolTest* p = objects[j];
206 delete p;
207 }
208 });
209
210 threads.push_back(std::move(t1));
211 }
212
213 for (int i = 0; i < nThread; i++)
214 {
215 threads[i].join();
216 }
217 }
218
219 {
220 SPICESTEST_PROFILE_SCOPE("malloc / free");
221
222 std::vector<std::thread> threads;
223 for (int i = 0; i < nThread; i++)
224 {
225 std::thread t1([&]() {
226 std::vector<MemoryPoolTest*> objects;
227 objects.resize(nCount);
228
229 for (int j = 0; j < nCount; j++)
230 {
231 MemoryPoolTest* p = static_cast<MemoryPoolTest*>(malloc(4 * sizeof(MemoryPoolTest)));
232 new(p)MemoryPoolTest;
233
234 objects[j] = std::move(p);
235 }
236
237 for (int j = 0; j < nCount; j++)
238 {
239 MemoryPoolTest* p = objects[j];
240
241 p->~MemoryPoolTest();
242 free(p);
243 }
244 });
245
246 threads.push_back(std::move(t1));
247 }
248
249 for (int i = 0; i < nThread; i++)
250 {
251 threads[i].join();
252 }
253 }
254
255 {
256 SPICESTEST_PROFILE_SCOPE("MemoryPool::Alloc / MemoryPool::Free");
257
258 std::vector<std::thread> threads;
259 for (int i = 0; i < nThread; i++)
260 {
261 std::thread t1([&]() {
262 std::vector<MemoryPoolTest*> objects;
263 objects.resize(nCount);
264
265 for (int j = 0; j < nCount; j++)
266 {
267 MemoryPoolTest* p = static_cast<MemoryPoolTest*>(Spices::MemoryPool::Alloc(4 * sizeof(MemoryPoolTest)));
268 new(p)MemoryPoolTest;
269
270 objects[j] = std::move(p);
271 }
272
273 for (int j = 0; j < nCount; j++)
274 {
275 MemoryPoolTest* p = objects[j];
276
277 p->~MemoryPoolTest();
279 }
280 });
281
282 threads.push_back(std::move(t1));
283 }
284
285 for (int i = 0; i < nThread; i++)
286 {
287 threads[i].join();
288 }
289 }
290 }
291
292 /**
293 * @brief Testing Spices::MemoryPool Performance.
294 */
296
298
299 static constexpr int nThread = 10;
300 static constexpr int nCount = 50000;
301
302 {
303 SPICESTEST_PROFILE_SCOPE("new / delete");
304
305 std::vector<std::thread> threads;
306 for (int i = 0; i < nThread; i++)
307 {
308 std::thread t1([&]() {
309 std::vector<MemoryPoolTest*> objects;
310 objects.resize(nCount);
311
312 for (int j = 0; j < nCount; j++)
313 {
315
316 objects[j] = std::move(p);
317 }
318
319 for (int j = 0; j < nCount; j++)
320 {
321 MemoryPoolTest* p = objects[j];
322 delete p;
323 }
324 });
325
326 threads.push_back(std::move(t1));
327 }
328
329 for (int i = 0; i < nThread; i++)
330 {
331 threads[i].join();
332 }
333 }
334
335 {
336 SPICESTEST_PROFILE_SCOPE("malloc / free");
337
338 std::vector<std::thread> threads;
339 for (int i = 0; i < nThread; i++)
340 {
341 std::thread t1([&]() {
342 std::vector<MemoryPoolTest*> objects;
343 objects.resize(nCount);
344
345 for (int j = 0; j < nCount; j++)
346 {
347 MemoryPoolTest* p = static_cast<MemoryPoolTest*>(malloc(4 * sizeof(MemoryPoolTest)));
348 new(p)MemoryPoolTest;
349
350 objects[j] = std::move(p);
351 }
352
353 for (int j = 0; j < nCount; j++)
354 {
355 MemoryPoolTest* p = objects[j];
356
357 p->~MemoryPoolTest();
358 free(p);
359 }
360 });
361
362 threads.push_back(std::move(t1));
363 }
364
365 for (int i = 0; i < nThread; i++)
366 {
367 threads[i].join();
368 }
369 }
370
371 {
372 SPICESTEST_PROFILE_SCOPE("MemoryPool::Alloc / MemoryPool::Free");
373
374 std::vector<std::thread> threads;
375 for (int i = 0; i < nThread; i++)
376 {
377 std::thread t1([&]() {
378 std::vector<MemoryPoolTest*> objects;
379 objects.resize(nCount);
380
381 for (int j = 0; j < nCount; j++)
382 {
383 MemoryPoolTest* p = static_cast<MemoryPoolTest*>(Spices::MemoryPool::Alloc(4 * sizeof(MemoryPoolTest)));
384 new(p)MemoryPoolTest;
385
386 objects[j] = std::move(p);
387 }
388
389 for (int j = 0; j < nCount; j++)
390 {
391 MemoryPoolTest* p = objects[j];
392
393 p->~MemoryPoolTest();
395 }
396 });
397
398 threads.push_back(std::move(t1));
399 }
400
401 for (int i = 0; i < nThread; i++)
402 {
403 threads[i].join();
404 }
405 }
406 }
407
408 /**
409 * @brief Testing Spices::MemoryPool Performance.
410 */
412
414
415 static constexpr int nThread = 1;
416 static constexpr int nCount = 500000;
417 static constexpr int maxBytes = 1024;
418
419 {
420 SPICESTEST_PROFILE_SCOPE("malloc / free");
421
422 std::vector<std::thread> threads;
423 for (int i = 0; i < nThread; i++)
424 {
425 std::thread t1([&]() {
426 std::vector<void*> objects;
427 objects.resize(nCount);
428
429 for (int j = 0; j < nCount; j++)
430 {
431 const size_t bytes = maxBytes * std::rand() / float(RAND_MAX);
432 void* p = malloc(bytes);
433
434 objects[j] = std::move(p);
435 }
436
437 for (int j = 0; j < nCount; j++)
438 {
439 void* p = objects[j];
440
441 free(p);
442 }
443 });
444
445 threads.push_back(std::move(t1));
446 }
447
448 for (int i = 0; i < nThread; i++)
449 {
450 threads[i].join();
451 }
452 }
453
454 {
455 SPICESTEST_PROFILE_SCOPE("MemoryPool::Alloc / MemoryPool::Free");
456
457 std::vector<std::thread> threads;
458 for (int i = 0; i < nThread; i++)
459 {
460 std::thread t1([&]() {
461 std::vector<void*> objects;
462 objects.resize(nCount);
463
464 for (int j = 0; j < nCount; j++)
465 {
466 size_t bytes = maxBytes * std::rand() / float(RAND_MAX);
467 bytes = std::max((size_t)8, bytes);
468 void* p = Spices::MemoryPool::Alloc(bytes);
469
470 objects[j] = std::move(p);
471 }
472
473 for (int j = 0; j < nCount; j++)
474 {
475 void* p = objects[j];
476
478 }
479 });
480
481 threads.push_back(std::move(t1));
482 }
483
484 for (int i = 0; i < nThread; i++)
485 {
486 threads[i].join();
487 }
488 }
489 }
490
491 /**
492 * @brief Testing Spices::MemoryPool Performance.
493 */
495
497
498 static constexpr int nThread = 10;
499 static constexpr int nCount = 50000;
500 static constexpr int maxBytes = 1024;
501
502 {
503 SPICESTEST_PROFILE_SCOPE("malloc / free");
504
505 std::vector<std::thread> threads;
506 for (int i = 0; i < nThread; i++)
507 {
508 std::thread t1([&]() {
509 std::vector<void*> objects;
510 objects.resize(nCount);
511
512 for (int j = 0; j < nCount; j++)
513 {
514 const size_t bytes = maxBytes * std::rand() / float(RAND_MAX);
515 void* p = malloc(bytes);
516
517 objects[j] = std::move(p);
518 }
519
520 for (int j = 0; j < nCount; j++)
521 {
522 void* p = objects[j];
523
524 free(p);
525 }
526 });
527
528 threads.push_back(std::move(t1));
529 }
530
531 for (int i = 0; i < nThread; i++)
532 {
533 threads[i].join();
534 }
535 }
536
537 {
538 SPICESTEST_PROFILE_SCOPE("MemoryPool::Alloc / MemoryPool::Free");
539
540 std::vector<std::thread> threads;
541 for (int i = 0; i < nThread; i++)
542 {
543 std::thread t1([&]() {
544 std::vector<void*> objects;
545 objects.resize(nCount);
546
547 for (int j = 0; j < nCount; j++)
548 {
549 size_t bytes = maxBytes * std::rand() / float(RAND_MAX);
550 bytes = std::max((size_t)8, bytes);
551 void* p = Spices::MemoryPool::Alloc(bytes);
552
553 objects[j] = std::move(p);
554 }
555
556 for (int j = 0; j < nCount; j++)
557 {
558 void* p = objects[j];
559
561 }
562 });
563
564 threads.push_back(std::move(t1));
565 }
566
567 for (int i = 0; i < nThread; i++)
568 {
569 threads[i].join();
570 }
571 }
572 }
573
574#if 0
575
576 /**
577 * @brief Testing Spices::MemoryPool Stress.
578 */
580
582
583 constexpr int nThreads = 8;
584 constexpr int nCounts_0 = 1 * 1000000 * 5; // 1G
585 constexpr int nCounts_1 = 1 * 4000 * 5; // 1G
586 constexpr int nCounts_2 = 1 * 1000 * 5; // 1G
587 constexpr int nCounts_3 = 1 * 128 * 5; // 1G
588
590
591 for (int i = 0; i < nThreads; i++)
592 {
593 std::thread t([&]() {
594
595 for(;;)
596 {
597 void** objects = new void*[nCounts_0 + nCounts_1 + nCounts_2 + nCounts_3];
598
599 // 8 - 1024 B
600 for (int i = 0; i < nCounts_0; i++)
601 {
602 float rand = std::rand() / float(RAND_MAX);
603 size_t bytes = rand * (1024 - 8) + 8 + 1;
604
606 }
607
608 // 1 - 256 KB
609 for (int i = nCounts_0; i < nCounts_0 + nCounts_1; i++)
610 {
611 float rand = std::rand() / float(RAND_MAX);
612 size_t bytes = rand * (256 * 1024 - 1024) + 1024 + 1;
613
615 }
616
617 // 256 - 4 * 256 KB
618 for (int i = nCounts_0 + nCounts_1; i < nCounts_0 + nCounts_1 + nCounts_2; i++)
619 {
620 float rand = std::rand() / float(RAND_MAX);
621 size_t bytes = rand * (4 * 256 * 1024 - 256 * 1024) + 256 * 1024 + 1;
622
623 objects[i] = Spices::MemoryPool::Alloc(3 * 256 * 1024);
624 }
625
626 // 1 - 8 M
628 {
629 float rand = std::rand() / float(RAND_MAX);
630 size_t bytes = rand * (8 * 1024 * 1024 - 1024 * 1024) + 1024 * 1024 + 1;
631
633 }
634
635 for (int i = 0; i < nCounts_0 + nCounts_1 + nCounts_2 + nCounts_3; i++)
636 {
638 }
639
640 delete[] objects;
641 }
642 });
643
645 }
646
647 for (int i = 0; i < nThreads; i++)
648 {
649 threads[i].join();
650 }
651
652 std::cout << "End To Here" << std::endl;
653 }
654
655#endif
656}
#define DELEGATE_ONE_PARAM(name, p0)
Use this macro to instance a Delegate Class. One Parameter Specific.
#define DELEGATE_THREE_PARAM(name, p0, p1, p2)
Use this macro to instance a Delegate Class. Three Parameter Specific.
#define DELEGATE_SIX_PARAM(name, p0, p1, p2, p3, p4, p5)
Use this macro to instance a Delegate Class. Six Parameter Specific.
#define DELEGATE_FIVE_PARAM(name, p0, p1, p2, p3, p4)
Use this macro to instance a Delegate Class. Five Parameter Specific.
#define DELEGATE_NONE_PARAM(name)
Use this macro to instance a Delegate Class. None Parameter Specific.
#define DELEGATE_SEVEN_PARAM(name, p0, p1, p2, p3, p4, p5, p6)
Use this macro to instance a Delegate Class. Seven Parameter Specific.
#define DELEGATE_EIGHT_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7)
Use this macro to instance a Delegate Class. Eight Parameter Specific.
#define DELEGATE_TWO_PARAM(name, p0, p1)
Use this macro to instance a Delegate Class. Two Parameter Specific.
#define DELEGATE_FOUR_PARAM(name, p0, p1, p2, p3)
Use this macro to instance a Delegate Class. Four Parameter Specific.
#define DELEGATE_NINE_PARAM(name, p0, p1, p2, p3, p4, p5, p6, p7, p8)
Use this macro to instance a Delegate Class. Nine Parameter Specific.
#define SPICES_FUNC_SIG
#define SPICESTEST_PROFILE_SCOPE_LINE2(name, line)
#define SPICESTEST_PROFILE_SCOPE(name)
#define SPICES_PROFILE
#define SPICESTEST_PROFILE_END_SESSION()
#define SPICESTEST_PROFILE_BEGIN_SESSION(name, filepath)
#define SPICESTEST_PROFILE_SCOPE_LINE(name, line)
#define SPICESTEST_PROFILE_FUNCTION()
void Test0(int a, int b)
Basic Class Function.
void Test(float f)
Basic Override Class Function.
void Test()
Basic Override Class Function.
static void Test1()
Static Class Function.
Test Function Class.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
Instance Delegate Class.
InstrumentationTimer(const char *name)
std::chrono::time_point< std::chrono::steady_clock > m_StartTimepoint
Instrumentor(Instrumentor &&)=delete
static Instrumentor & Get()
void BeginSession(const std::string &name, const std::string &filepath="results.json")
void WriteProfile(const ProfileResult &result)
InstrumentationSession * m_CurrentSession
std::ofstream m_OutputStream
Instrumentor(const Instrumentor &)=delete
MemoryPoolTest2(const MemoryPoolTest2 &)=delete
MemoryPoolTest2 & operator=(const MemoryPoolTest2 &)=delete
static constexpr size_t y
std::array< std::array< int, x >, y > datas
static constexpr size_t x
MemoryPoolTest(const MemoryPoolTest &)=delete
MemoryPoolTest & operator=(const MemoryPoolTest &)=delete
std::tuple< int, float, void * > m_Tuple
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
static constexpr size_t n2
Iter counts 2.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
static constexpr size_t n
Iter counts.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
std::unique_ptr< Spices::ObjectPool< Object > > m_ObjectPool
ObjectPool.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
static constexpr size_t n
ObjectPool objects number.
The interface is inherited from testing::Test. Registry on Initialize.
virtual ~Object()=default
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::PageCache pc
PageCache.
static constexpr size_t n
Test iter number.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
The interface is inherited from testing::Test. Registry on Initialize.
Declare Empty Class.
ThreadCacheTest & operator=(const ThreadCacheTest &)=delete
std::tuple< int, float, void * > m_Tuple
ThreadCacheTest(const ThreadCacheTest &)=delete
static constexpr size_t n
Iter counts.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
Spices::ThreadCache tc
ThreadCache.
The interface is inherited from testing::Test. Registry on Initialize.
void Test(float f)
Basic Override Class Function.
void Test()
Basic Override Class Function.
void TearDown() override
Testing class TearDown function.
std::vector< scl::directed_acyclic_node > m_Nodes
void SetUp() override
Testing class initialize function.
The interface is inherited from testing::Test. Registy on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
The interface is inherited from testing::Test. Registry on Initialize.
scl::kd_tree< 2 > m_KDTree
Create a KDTree with 2 dimensions.
Definition KDTree_test.h:57
void TearDown() override
Testing class TearDown function.
Definition KDTree_test.h:52
void SetUp() override
Testing class initialize function.
Definition KDTree_test.h:27
The interface is inherited from testing::Test. Registry on Initialize.
Definition KDTree_test.h:21
scl::linked_unordered_map< int, std::string > c1
scl::linked_unordered_map< float, std::string > c2
scl::linked_unordered_map< std::string, std::string > c0
void SetUp() override
Testing class initialize function.
void TearDown() override
Testing class TearDown function.
The interface is inherited from testing::Test. Registry on Initialize.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
void TearDown() override
Testing class TearDown function.
Unit Test for RuntimeMemoryBlock.
void TearDown() override
The interface is inherited from testing::Test. Call before Destructor.
void SetUp() override
The interface is inherited from testing::Test. Registry on Initialize.
The interface is inherited from testing::Test. Registry on Initialize.
static std::string GetClassString(ClassType t)
Get Class Name as string.
Class Static Function Library.
static bool FileLibrary_Size(const FileHandle *handle, uint64_t *out_size)
Calculate The file size.
static bool FileLibrary_Read(const FileHandle *handle, uint64_t data_size, void *out_data, uint64_t *out_bytes_read)
Read Specific size of data form the current file handle pointer, and move pointer the same size.
static bool FileLibrary_Write_Line(const FileHandle *handle, const char *text)
Write one line data to the file handle pointer.
static bool FileLibrary_Write(const FileHandle *handle, uint64_t data_size, const void *data, uint64_t *out_bytes_written)
Write given data to the file handle pointer.
static bool FileLibrary_Open(const char *path, FileModes mode, bool binary, FileHandle *out_handle)
Open the file using given string.
static void FileLibrary_Close(FileHandle *handle)
Close the file by the file handle.
static bool FileLibrary_Delete(const char *filePath)
Delete a file from disk.
static bool FileLibrary_CopyFile(std::string srcFilePath, std::string dstFilePath)
Copy a file to dst path.
static bool FileLibrary_Read_Line(const FileHandle *handle, uint64_t max_length, char *line_buf, uint64_t *out_line_length)
Read one line from the current file handle pointer, and move pointer the same size.
static bool FileLibrary_Exists(const char *path)
Determine whether the given string is existing a file.
static bool FileLibrary_Read_all_bytes(const FileHandle *handle, char *out_bytes, uint64_t *out_bytes_read)
Read all data form the current file handle pointer.
File Static Function Library.
Definition FileLibrary.h:49
static void Init()
Init Log.
Definition Log.cpp:24
static void ShutDown()
Shutdown Log.
Definition Log.cpp:82
static void Free(void *ptr)
Free memory entry point.
static void *& PointerSpace(void *obj)
Get object first 4/8 bytes as a pointer.
MemoryPool Class.
Definition MemoryPool.h:22
Page memory cache. Third level of memory allocator.
Definition PageCache.h:21
static bool CloseProcess(const char *processName)
Close a Process with command.
static bool OpenProcess(const char *processPath, const char *commandLine="")
Open a Process with command.
static float ProcessMemoryInUsed()
Get this Process Memory used( GB ).
Process Static Function Library.
static bool StringsEqual(const char *str0, const char *str1)
Determine if the strings given are equal. Platform Specific.
String Static Function Library.
Thread memory cache. First level of memory allocator.
Definition ThrealCache.h:19
static bool SetThreadName(const std::string &name)
Set Thread name.
Thread Static Function Library.
behave_state_list. wrapper of combing all state behaves.
bool Empty() const
Determine if this list is empty.
Definition FreeList.h:50
void Push(void *obj)
Recycle a object memory to this free list.
Definition FreeList.cpp:13
void *& Begin()
Get current pointer (no const & reference version).
Definition FreeList.h:94
void *& End()
Get end pointer (no const & reference version).
Definition FreeList.h:100
Free list for memory pool.
Definition FreeList.h:16
The kd_tree with K dimensions container Class. K the number of dimensions. Every node in the tree is ...
Definition KDTree.h:27
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
void build()
Malloc a memory to begin_.
void add_element(const std::string &name, const std::string &type)
Add a element to object_, means a memory block will be occupied with given param type.
runtime_memory_block()=default
Constructor Function.
void * get_addr() const
Get the begin_.
The container is wrapper of a continue memory block. Used in Material::BuildMaterial(),...
Bidirectional cyclic linked list for span.
Definition SpanList.h:73
span * m_Next
next span.
Definition SpanList.h:41
span * m_Prev
previous span.
Definition SpanList.h:46
Used for manage multiple page memory.
Definition SpanList.h:15
simple tree.
Definition Tree.h:18
This Class is similar to std::vector, the difference between that is this one allocates memory by mal...
Definition Vector.h:18
int main(int argc, char **argv)
The Entry of SpicesTest.
Definition main.cpp:76
constexpr auto CleanupOutputString(const char(&expr)[N], const char(&remove)[K])
TEST_F(free_list_test, PushPop)
Testing scl::free_list::Push/Pop.
TEST_F(runtime_memory_block_test, Initialize)
Testing if initialize successfully.
TEST_F(directed_acyclic_graph_test, Addnode)
Testing if add node successfully.
TEST_F(span_list_test, Initialize)
Testing scl::span_list::Initialize.
TEST_F(linked_unordered_map_test, Initialize)
Testing if initialize successfully.
TEST_F(kd_tree_test, Insert)
Testing if Insert successfully.
Definition KDTree_test.h:63
void DelegateTestT(Args ...args)
Template Function.
TEST_F(MemoryPool_test, PointerSpace)
Testing Spices::MemoryPool::PointerSpace.
TEST(tuple_test, IterTuple)
Testing std::tuple Helper Function.
Definition Tuple_test.h:17
TEST_F(ObjectPool_test, Initialize)
Testing Spices::ObjectPool::Initialize.
TEST_F(Delegate_test, Bind)
Testing if bind successfully.
TEST_F(ThreadCache_test, AllocateDeallocate)
Testing Spices::ThreadCache::Allocate/Deallocate.
TEST_F(PageCache_test, NewSpan)
Testing Spices::PageCache::NewSpan.
FileModes
file mode
Definition FileLibrary.h:32
@ FILE_MODE_READ
model : read
Definition FileLibrary.h:37
@ FILE_MODE_WRITE
model : write
Definition FileLibrary.h:42
void IterTuple(Tuple &tuple, Function &&f)
Iter a tuple.
Definition Tuple.h:34
std::thread::id ThreadID
std::chrono::microseconds ElapsedTime
FloatingPointMicroseconds Start
void * handle
FILE* handle. Need cast while use.
Definition FileLibrary.h:21
bool is_valid
Is this handle Valid.
Definition FileLibrary.h:26
This Struct is FILE* handle pointer Wrapper.
Definition FileLibrary.h:15
bool operator==(const String2 &other) const
equal operation.
Definition Math.h:88
double string
Definition Math.h:63
bool operator==(const UInt2 &other) const
equal operation.
Definition Math.h:42
UInt2(const uint32_t &x, const uint32_t &y)
Constructor Function.
Definition Math.h:30
double unsigned int
Definition Math.h:17