16template<
typename ElementType>
19 stream <<
"-------- Dynamic Allocation Test" <<
nl <<
endl;
23 std::allocator<ElementType> alloc;
25 stream <<
"Dynamically allocate " << element_count
27 <<
" using std::allocator() " <<
nl;
29 for(
size_t i = 0; i < test_count; ++i)
31 auto ptr_d = (ElementType*)alloc.allocate(element_count);
34 for(
size_t i = 0; i < element_count; ++i)
35 ptr_d[i] = (ElementType)i;
39 alloc.deallocate(ptr_d, element_count);
46 dynamic_allocation_test<int>(5, 1'000'000);
51 std::shared_ptr<int[]> ptr = std::make_shared<int[]>((
size_t)50);
void benchmarking_new_vs_malloc()
tpf::chrono_random::stop_watch stop_watch
void dynamic_allocation_test(size_t test_count, size_t element_count)
std::string elapsed_time(bool bReset=true, TimeUnit dummy_time=TimeUnit{}) const
Stream output operators << are implemented.
#define Tpf_GetTypeName(type_arg)
A macro that returns type_arg's string name.