|
Packit Service |
724aca |
/*
|
|
Packit Service |
724aca |
* Copyright (C) 2015 - 2018 Intel Corporation.
|
|
Packit Service |
724aca |
* All rights reserved.
|
|
Packit Service |
724aca |
*
|
|
Packit Service |
724aca |
* Redistribution and use in source and binary forms, with or without
|
|
Packit Service |
724aca |
* modification, are permitted provided that the following conditions are met:
|
|
Packit Service |
724aca |
* 1. Redistributions of source code must retain the above copyright notice(s),
|
|
Packit Service |
724aca |
* this list of conditions and the following disclaimer.
|
|
Packit Service |
724aca |
* 2. Redistributions in binary form must reproduce the above copyright notice(s),
|
|
Packit Service |
724aca |
* this list of conditions and the following disclaimer in the documentation
|
|
Packit Service |
724aca |
* and/or other materials provided with the distribution.
|
|
Packit Service |
724aca |
*
|
|
Packit Service |
724aca |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
|
|
Packit Service |
724aca |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
Packit Service |
724aca |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
Packit Service |
724aca |
* EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
Packit Service |
724aca |
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
Packit Service |
724aca |
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
Packit Service |
724aca |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
Packit Service |
724aca |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
|
|
Packit Service |
724aca |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
Packit Service |
724aca |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
Packit Service |
724aca |
*/
|
|
Packit Service |
724aca |
#pragma once
|
|
Packit Service |
724aca |
#include "Configuration.hpp"
|
|
Packit Service |
724aca |
#include "Stats.hpp"
|
|
Packit Service |
724aca |
#include "FunctionCalls.hpp"
|
|
Packit Service |
724aca |
|
|
Packit Service |
724aca |
#include <stdio.h>
|
|
Packit Service |
724aca |
|
|
Packit Service |
724aca |
class ConsoleLog
|
|
Packit Service |
724aca |
{
|
|
Packit Service |
724aca |
public:
|
|
Packit Service |
724aca |
static void print_stats(TimeStats &stats, unsigned allocator_type,
|
|
Packit Service |
724aca |
unsigned func_calls)
|
|
Packit Service |
724aca |
{
|
|
Packit Service |
724aca |
if(stats.stats.count(allocator_type)) {
|
|
Packit Service |
724aca |
if(stats.stats[allocator_type].count(func_calls)) {
|
|
Packit Service |
724aca |
MethodStats method_stats = stats.stats[allocator_type][func_calls];
|
|
Packit Service |
724aca |
printf(" %20s (%u) | %7s | %10f.s | %10f.s | %zu bytes/%f MB \n",
|
|
Packit Service |
724aca |
AllocatorTypes::allocator_name(allocator_type).c_str(),
|
|
Packit Service |
724aca |
allocator_type,
|
|
Packit Service |
724aca |
FunctionCalls::function_name(func_calls).c_str(),
|
|
Packit Service |
724aca |
method_stats.total_time,
|
|
Packit Service |
724aca |
method_stats.average_time,
|
|
Packit Service |
724aca |
method_stats.allocation_size,
|
|
Packit Service |
724aca |
convert_bytes_to_mb(method_stats.allocation_size)
|
|
Packit Service |
724aca |
);
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
|
|
Packit Service |
724aca |
static void print_table(TimeStats &stats)
|
|
Packit Service |
724aca |
{
|
|
Packit Service |
724aca |
printf("\n====== Allocators function calls performance =================================================\n");
|
|
Packit Service |
724aca |
printf(" %20s Id: Method: Total time: Average time: Allocated memory bytes/MB: \n",
|
|
Packit Service |
724aca |
"Allocator:");
|
|
Packit Service |
724aca |
for (unsigned i=0; i<=AllocatorTypes::MEMKIND_HBW_PREFERRED; i++) {
|
|
Packit Service |
724aca |
for (unsigned func_call=FunctionCalls::FREE+1;
|
|
Packit Service |
724aca |
func_call
|
|
Packit Service |
724aca |
print_stats(stats, i, func_call);
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
printf("==============================================================================================\n");
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
|
|
Packit Service |
724aca |
static void print_requested_memory(TimeStats &stats, std::string test_name)
|
|
Packit Service |
724aca |
{
|
|
Packit Service |
724aca |
printf("\n====== Requested memory stats for %s =================\n",
|
|
Packit Service |
724aca |
test_name.c_str());
|
|
Packit Service |
724aca |
printf("Total requested allocations: %zu bytes/%f MB. \n",stats.get_allocated(),
|
|
Packit Service |
724aca |
convert_bytes_to_mb(stats.get_allocated()));
|
|
Packit Service |
724aca |
printf("Total requested deallocations: %zu bytes/%f MB. \n",
|
|
Packit Service |
724aca |
stats.get_deallocated(), convert_bytes_to_mb(stats.get_deallocated()));
|
|
Packit Service |
724aca |
printf("=====================================================================\n");
|
|
Packit Service |
724aca |
}
|
|
Packit Service |
724aca |
};
|