MCPcopy Create free account
hub / github.com/TheForceEngine/TheForceEngine / region_test

Function region_test

TheForceEngine/TFE_Memory/memoryRegion.cpp:804–841  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

802 const u64 _testAllocSize[] = { 16, 32, 24, 100, 200, 500, 327, 537, 200, 17, 57, 387, 874, 204, 100, 22 };
803
804 void region_test()
805 {
806 u64 start = TFE_System::getCurrentTimeInTicks();
807 const u64 mask = TFE_ARRAYSIZE(_testAllocSize) - 1;
808 void* alloc[ALLOC_COUNT];
809 for (s32 i = 0; i < ALLOC_COUNT; i++)
810 {
811 alloc[i] = malloc(_testAllocSize[i&mask]);
812 if ((i % 16) == 0)
813 {
814 free(alloc[i]);
815 alloc[i] = nullptr;
816 }
817 }
818 u64 mallocDelta = TFE_System::getCurrentTimeInTicks() - start;
819 // Free memory.
820 for (s32 i = 0; i < ALLOC_COUNT; i++)
821 {
822 free(alloc[i]);
823 }
824
825 MemoryRegion* region = region_create("Test", 32 * 1024 * 1024);
826 start = TFE_System::getCurrentTimeInTicks();
827 for (s32 i = 0; i < ALLOC_COUNT; i++)
828 {
829 alloc[i] = region_alloc(region, _testAllocSize[i&mask]);
830 if ((i % 16) == 0)
831 {
832 region_free(region, alloc[i]);
833 alloc[i] = nullptr;
834 }
835 }
836 u64 regionDelta = TFE_System::getCurrentTimeInTicks() - start;
837 // Free memory.
838 region_destroy(region);
839
840 TFE_System::logWrite(LOG_MSG, "MemoryRegion", "Malloc: %f, Region: %f", TFE_System::convertFromTicksToSeconds(mallocDelta), TFE_System::convertFromTicksToSeconds(regionDelta));
841 }
842}

Callers

nothing calls this directly

Calls 8

getCurrentTimeInTicksFunction · 0.85
region_createFunction · 0.85
region_allocFunction · 0.85
region_freeFunction · 0.85
region_destroyFunction · 0.85
logWriteFunction · 0.85
freeFunction · 0.50

Tested by

no test coverage detected