From 2785519443c57484b1dc86b24fac72232dd4ef2b Mon Sep 17 00:00:00 2001 From: Brett Laptop Date: Mon, 11 Mar 2024 12:14:14 -0400 Subject: [PATCH] memory test --- CMakeLists.txt | 2 +- libs/BLT | 2 +- tests/src/tests4.cpp | 70 +++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 68 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25ad60a..fde3f88 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.25) -project(lilfbtf5 VERSION 0.1.12) +project(lilfbtf5 VERSION 0.1.13) option(ENABLE_ADDRSAN "Enable the address sanitizer" OFF) option(ENABLE_UBSAN "Enable the ub sanitizer" OFF) diff --git a/libs/BLT b/libs/BLT index 263bbc8..1abd321 160000 --- a/libs/BLT +++ b/libs/BLT @@ -1 +1 @@ -Subproject commit 263bbc88cf1b9423054cdbdbcdd9f31366184920 +Subproject commit 1abd3214be23289b26f4cf2329c4a58c0c7be04b diff --git a/tests/src/tests4.cpp b/tests/src/tests4.cpp index 21e33ed..c486b82 100644 --- a/tests/src/tests4.cpp +++ b/tests/src/tests4.cpp @@ -29,6 +29,8 @@ #include #include "blt/profiling/profiler_v2.h" #include "blt/std/allocator.h" +#include "blt/std/format.h" +#include "blt/std/system.h" namespace fb { @@ -876,7 +878,7 @@ namespace fb alloc_2.destroy(children[i]); alloc_2.deallocate(children[i]); } - alloc_2.deallocate(children); + alloc_2.deallocate(children, type.argc()); } }; @@ -1007,7 +1009,7 @@ namespace fb alloc_2.destroy(children[i]); alloc_2.deallocate(children[i]); } - alloc_2.deallocate(children); + alloc_2.deallocate(children, type.argc()); } }; @@ -1138,7 +1140,7 @@ namespace fb alloc_2.destroy(children[i]); alloc_2.deallocate(children[i]); } - alloc_2.deallocate(children); + alloc_2.deallocate(children, type.argc()); } }; @@ -1272,7 +1274,7 @@ namespace fb alloc_2.destroy(children[i]); alloc_2.deallocate(children[i]); } - alloc_2.deallocate(children); + alloc_2.deallocate(children, type.argc()); } }; @@ -1348,62 +1350,122 @@ namespace fb void run_any_t() { + alloc_2.resetStats(); engine.reset(); tree_any love[size]; + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Construction", "any_t tree"); for (auto& i : love) i.create(tree_size); BLT_END_INTERVAL("Tree Construction", "any_t tree"); BLT_INFO("Construction any_t finished"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Evaluation", "any_t tree"); for (auto& i : love) blt::black_box(i.evaluate()); BLT_END_INTERVAL("Tree Evaluation", "any_t tree"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } + BLT_INFO("Peak bytes for any_t: %s, blocks: %ld", blt::string::fromBytes(alloc_2.getStats().getPeakBytes()).c_str(), + alloc_2.getStats().getPeakBlocks()); } void run_any_t_variant() { + alloc_2.resetStats(); engine.reset(); tree_any_variant love[size]; + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Construction", "any_t_variant tree"); for (auto& i : love) i.create(tree_size); BLT_END_INTERVAL("Tree Construction", "any_t_variant tree"); BLT_INFO("Construction any_t_variant finished"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Evaluation", "any_t_variant tree"); for (auto& i : love) blt::black_box(i.evaluate()); BLT_END_INTERVAL("Tree Evaluation", "any_t_variant tree"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } + BLT_INFO("Peak bytes for any_t_variant: %s, blocks: %ld", blt::string::fromBytes(alloc_2.getStats().getPeakBytes()).c_str(), + alloc_2.getStats().getPeakBlocks()); } void run_any_t_union() { + alloc_2.resetStats(); engine.reset(); tree_any_union love[size]; + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Construction", "any_t_union tree"); for (auto& i : love) i.create(tree_size); BLT_END_INTERVAL("Tree Construction", "any_t_union tree"); BLT_INFO("Construction any_t_union finished"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Evaluation", "any_t_union tree"); for (auto& i : love) blt::black_box(i.evaluate()); BLT_END_INTERVAL("Tree Evaluation", "any_t_union tree"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } + BLT_INFO("Peak bytes for any_t_union: %s, blocks: %ld", blt::string::fromBytes(alloc_2.getStats().getPeakBytes()).c_str(), + alloc_2.getStats().getPeakBlocks()); } void run_std_any_t() { + alloc_2.resetStats(); engine.reset(); tree_std_any love[size]; + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Construction", "std::any tree"); for (auto& i : love) i.create(tree_size); BLT_END_INTERVAL("Tree Construction", "std::any tree"); BLT_INFO("Construction std::any finished"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } BLT_START_INTERVAL("Tree Evaluation", "std::any tree"); for (auto& i : love) blt::black_box(i.evaluate()); BLT_END_INTERVAL("Tree Evaluation", "std::any tree"); + { + auto v = blt::system::get_memory_process(); + BLT_DEBUG("Currently %ld bytes aka %s in memory", v.resident, blt::string::fromBytes(v.resident).c_str()); + } + BLT_INFO("Peak bytes for std::any: %s, blocks: %ld", blt::string::fromBytes(alloc_2.getStats().getPeakBytes()).c_str(), + alloc_2.getStats().getPeakBlocks()); } void test4()