mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator.git
synced 2024-11-30 02:04:35 +00:00
Added writing results of linear allocator benchmark to file "LinearAllocator.csv".
This commit is contained in:
parent
740b08f6eb
commit
33d2ce744b
@ -7,6 +7,8 @@
|
|||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
|
||||||
|
static const char* CODE_DESCRIPTION = "Foo";
|
||||||
|
|
||||||
enum CONFIG_TYPE {
|
enum CONFIG_TYPE {
|
||||||
CONFIG_TYPE_MINIMUM,
|
CONFIG_TYPE_MINIMUM,
|
||||||
CONFIG_TYPE_SMALL,
|
CONFIG_TYPE_SMALL,
|
||||||
@ -213,6 +215,15 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static void CurrentTimeToStr(std::string& out)
|
||||||
|
{
|
||||||
|
time_t rawTime; time(&rawTime);
|
||||||
|
struct tm timeInfo; localtime_s(&timeInfo, &rawTime);
|
||||||
|
char timeStr[128];
|
||||||
|
strftime(timeStr, _countof(timeStr), "%c", &timeInfo);
|
||||||
|
out = timeStr;
|
||||||
|
}
|
||||||
|
|
||||||
VkResult MainTest(Result& outResult, const Config& config)
|
VkResult MainTest(Result& outResult, const Config& config)
|
||||||
{
|
{
|
||||||
assert(config.ThreadCount > 0);
|
assert(config.ThreadCount > 0);
|
||||||
@ -2093,7 +2104,7 @@ static void ManuallyTestLinearAllocator()
|
|||||||
vmaDestroyPool(g_hAllocator, pool);
|
vmaDestroyPool(g_hAllocator, pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BenchmarkLinearAllocatorCase(bool linear, bool empty, FREE_ORDER freeOrder)
|
static void BenchmarkLinearAllocatorCase(FILE* file, bool linear, bool empty, FREE_ORDER freeOrder)
|
||||||
{
|
{
|
||||||
RandomNumberGenerator rand{16223};
|
RandomNumberGenerator rand{16223};
|
||||||
|
|
||||||
@ -2212,18 +2223,43 @@ static void BenchmarkLinearAllocatorCase(bool linear, bool empty, FREE_ORDER fre
|
|||||||
|
|
||||||
vmaDestroyPool(g_hAllocator, pool);
|
vmaDestroyPool(g_hAllocator, pool);
|
||||||
|
|
||||||
|
const float allocTotalSeconds = ToFloatSeconds(allocTotalDuration);
|
||||||
|
const float freeTotalSeconds = ToFloatSeconds(freeTotalDuration);
|
||||||
|
|
||||||
printf(" LinearAlgorithm=%u %s FreeOrder=%s: allocations %g s, free %g s\n",
|
printf(" LinearAlgorithm=%u %s FreeOrder=%s: allocations %g s, free %g s\n",
|
||||||
linear ? 1 : 0,
|
linear ? 1 : 0,
|
||||||
empty ? "Empty" : "Not empty",
|
empty ? "Empty" : "Not empty",
|
||||||
FREE_ORDER_NAMES[(size_t)freeOrder],
|
FREE_ORDER_NAMES[(size_t)freeOrder],
|
||||||
ToFloatSeconds(allocTotalDuration),
|
allocTotalSeconds,
|
||||||
ToFloatSeconds(freeTotalDuration));
|
freeTotalSeconds);
|
||||||
|
|
||||||
|
if(file)
|
||||||
|
{
|
||||||
|
std::string currTime;
|
||||||
|
CurrentTimeToStr(currTime);
|
||||||
|
|
||||||
|
fprintf(file, "%s,%s,%u,%u,%s,%g,%g\n",
|
||||||
|
CODE_DESCRIPTION, currTime.c_str(),
|
||||||
|
linear ? 1 : 0,
|
||||||
|
empty ? 1 : 0,
|
||||||
|
FREE_ORDER_NAMES[(uint32_t)freeOrder],
|
||||||
|
allocTotalSeconds,
|
||||||
|
freeTotalSeconds);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void BenchmarkLinearAllocator()
|
static void BenchmarkLinearAllocator(FILE* file)
|
||||||
{
|
{
|
||||||
wprintf(L"Benchmark linear allocator\n");
|
wprintf(L"Benchmark linear allocator\n");
|
||||||
|
|
||||||
|
if(file)
|
||||||
|
{
|
||||||
|
fprintf(file,
|
||||||
|
"Code,Time,"
|
||||||
|
"Linear,Empty,Free order,"
|
||||||
|
"Allocation time (s),Deallocation time (s)\n");
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t freeOrderCount = 1;
|
uint32_t freeOrderCount = 1;
|
||||||
if(ConfigType >= CONFIG_TYPE::CONFIG_TYPE_LARGE)
|
if(ConfigType >= CONFIG_TYPE::CONFIG_TYPE_LARGE)
|
||||||
freeOrderCount = 3;
|
freeOrderCount = 3;
|
||||||
@ -2248,6 +2284,7 @@ static void BenchmarkLinearAllocator()
|
|||||||
for(uint32_t linearIndex = 0; linearIndex < 2; ++linearIndex)
|
for(uint32_t linearIndex = 0; linearIndex < 2; ++linearIndex)
|
||||||
{
|
{
|
||||||
BenchmarkLinearAllocatorCase(
|
BenchmarkLinearAllocatorCase(
|
||||||
|
file,
|
||||||
linearIndex ? 1 : 0, // linear
|
linearIndex ? 1 : 0, // linear
|
||||||
emptyIndex ? 0 : 1, // empty
|
emptyIndex ? 0 : 1, // empty
|
||||||
freeOrder); // freeOrder
|
freeOrder); // freeOrder
|
||||||
@ -3346,16 +3383,14 @@ static void WriteMainTestResult(
|
|||||||
float deallocationTimeAvgSeconds = ToFloatSeconds(result.DeallocationTimeAvg);
|
float deallocationTimeAvgSeconds = ToFloatSeconds(result.DeallocationTimeAvg);
|
||||||
float deallocationTimeMaxSeconds = ToFloatSeconds(result.DeallocationTimeMax);
|
float deallocationTimeMaxSeconds = ToFloatSeconds(result.DeallocationTimeMax);
|
||||||
|
|
||||||
time_t rawTime; time(&rawTime);
|
std::string currTime;
|
||||||
struct tm timeInfo; localtime_s(&timeInfo, &rawTime);
|
CurrentTimeToStr(currTime);
|
||||||
char timeStr[128];
|
|
||||||
strftime(timeStr, _countof(timeStr), "%c", &timeInfo);
|
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"%s,%s,%s,"
|
"%s,%s,%s,"
|
||||||
"%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%I64u,%I64u,%I64u\n",
|
"%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%.2f,%I64u,%I64u,%I64u\n",
|
||||||
codeDescription,
|
codeDescription,
|
||||||
timeStr,
|
currTime.c_str(),
|
||||||
testDescription,
|
testDescription,
|
||||||
totalTimeSeconds * 1e6f,
|
totalTimeSeconds * 1e6f,
|
||||||
allocationTimeMinSeconds * 1e6f,
|
allocationTimeMinSeconds * 1e6f,
|
||||||
@ -3402,10 +3437,8 @@ static void WritePoolTestResult(
|
|||||||
float deallocationTimeAvgSeconds = ToFloatSeconds(result.DeallocationTimeAvg);
|
float deallocationTimeAvgSeconds = ToFloatSeconds(result.DeallocationTimeAvg);
|
||||||
float deallocationTimeMaxSeconds = ToFloatSeconds(result.DeallocationTimeMax);
|
float deallocationTimeMaxSeconds = ToFloatSeconds(result.DeallocationTimeMax);
|
||||||
|
|
||||||
time_t rawTime; time(&rawTime);
|
std::string currTime;
|
||||||
struct tm timeInfo; localtime_s(&timeInfo, &rawTime);
|
CurrentTimeToStr(currTime);
|
||||||
char timeStr[128];
|
|
||||||
strftime(timeStr, _countof(timeStr), "%c", &timeInfo);
|
|
||||||
|
|
||||||
fprintf(file,
|
fprintf(file,
|
||||||
"%s,%s,%s,"
|
"%s,%s,%s,"
|
||||||
@ -3414,7 +3447,7 @@ static void WritePoolTestResult(
|
|||||||
// General
|
// General
|
||||||
codeDescription,
|
codeDescription,
|
||||||
testDescription,
|
testDescription,
|
||||||
timeStr,
|
currTime.c_str(),
|
||||||
// Config
|
// Config
|
||||||
config.ThreadCount,
|
config.ThreadCount,
|
||||||
(unsigned long long)config.PoolSize,
|
(unsigned long long)config.PoolSize,
|
||||||
@ -3501,8 +3534,6 @@ static void PerformCustomPoolTest(FILE* file)
|
|||||||
WritePoolTestResult(file, "Code desc", "Test desc", config, result);
|
WritePoolTestResult(file, "Code desc", "Test desc", config, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* CODE_DESCRIPTION = "Foo";
|
|
||||||
|
|
||||||
static void PerformMainTests(FILE* file)
|
static void PerformMainTests(FILE* file)
|
||||||
{
|
{
|
||||||
uint32_t repeatCount = 1;
|
uint32_t repeatCount = 1;
|
||||||
@ -3752,13 +3783,8 @@ static void PerformMainTests(FILE* file)
|
|||||||
assert(0);
|
assert(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch(config.FreeOrder)
|
desc6 += ',';
|
||||||
{
|
desc6 += FREE_ORDER_NAMES[(uint32_t)config.FreeOrder];
|
||||||
case FREE_ORDER::FORWARD: desc6 += ",Forward"; break;
|
|
||||||
case FREE_ORDER::BACKWARD: desc6 += ",Backward"; break;
|
|
||||||
case FREE_ORDER::RANDOM: desc6 += ",Random"; break;
|
|
||||||
default: assert(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char* testDescription = desc6.c_str();
|
const char* testDescription = desc6.c_str();
|
||||||
|
|
||||||
@ -4035,7 +4061,17 @@ void Test()
|
|||||||
TestLinearAllocator();
|
TestLinearAllocator();
|
||||||
ManuallyTestLinearAllocator();
|
ManuallyTestLinearAllocator();
|
||||||
TestLinearAllocatorMultiBlock();
|
TestLinearAllocatorMultiBlock();
|
||||||
BenchmarkLinearAllocator();
|
|
||||||
|
{
|
||||||
|
FILE* file;
|
||||||
|
fopen_s(&file, "LinearAllocator.csv", "w");
|
||||||
|
assert(file != NULL);
|
||||||
|
|
||||||
|
BenchmarkLinearAllocator(file);
|
||||||
|
|
||||||
|
fclose(file);
|
||||||
|
}
|
||||||
|
|
||||||
TestDefragmentationSimple();
|
TestDefragmentationSimple();
|
||||||
TestDefragmentationFull();
|
TestDefragmentationFull();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user