Blame test/heap_manager_init_perf_test.cpp

Packit 345191
/*
Packit 345191
 * Copyright (C) 2016 - 2018 Intel Corporation.
Packit 345191
 * All rights reserved.
Packit 345191
 *
Packit 345191
 * Redistribution and use in source and binary forms, with or without
Packit 345191
 * modification, are permitted provided that the following conditions are met:
Packit 345191
 * 1. Redistributions of source code must retain the above copyright notice(s),
Packit 345191
 *    this list of conditions and the following disclaimer.
Packit 345191
 * 2. Redistributions in binary form must reproduce the above copyright notice(s),
Packit 345191
 *    this list of conditions and the following disclaimer in the documentation
Packit 345191
 *    and/or other materials provided with the distribution.
Packit 345191
 *
Packit 345191
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY EXPRESS
Packit 345191
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
Packit 345191
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO
Packit 345191
 * EVENT SHALL THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
Packit 345191
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
Packit 345191
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
Packit 345191
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
Packit 345191
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
Packit 345191
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
Packit 345191
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 345191
 */
Packit 345191
#include <sstream>
Packit 345191
#include <vector>
Packit 345191
Packit 345191
#include "common.h"
Packit 345191
#include "allocator_perf_tool/Configuration.hpp"
Packit 345191
#include "allocator_perf_tool/AllocatorFactory.hpp"
Packit 345191
#include "allocator_perf_tool/HugePageOrganizer.hpp"
Packit 345191
Packit 345191
//Test heap managers initialization performance.
Packit 345191
class HeapManagerInitPerfTest: public :: testing::Test
Packit 345191
{
Packit 345191
Packit 345191
protected:
Packit 345191
    void SetUp()
Packit 345191
    {
Packit 345191
        //Calculate reference statistics.
Packit 345191
        ref_time = allocator_factory.initialize_allocator(
Packit 345191
                       AllocatorTypes::STANDARD_ALLOCATOR).total_time;
Packit 345191
    }
Packit 345191
Packit 345191
    void TearDown()
Packit 345191
    {}
Packit 345191
Packit 345191
    void run_test(unsigned allocator_type)
Packit 345191
    {
Packit 345191
        AllocatorFactory::initialization_stat stat =
Packit 345191
            allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_DEFAULT);
Packit 345191
Packit 345191
        post_test(stat);
Packit 345191
    }
Packit 345191
Packit 345191
    void post_test(AllocatorFactory::initialization_stat &stat)
Packit 345191
    {
Packit 345191
        //Calculate (%) distance to the reference time for function calls.
Packit 345191
        stat.ref_delta_time = allocator_factory.calc_ref_delta(ref_time,
Packit 345191
                                                               stat.total_time);
Packit 345191
Packit 345191
        std::stringstream elapsed_time;
Packit 345191
        elapsed_time << stat.total_time;
Packit 345191
Packit 345191
        std::stringstream ref_delta_time;
Packit 345191
        ref_delta_time << std::fixed << stat.ref_delta_time << std::endl;
Packit 345191
Packit 345191
        RecordProperty("elapsed_time", elapsed_time.str());
Packit 345191
        RecordProperty("ref_delta_time_percent_rate", ref_delta_time.str());
Packit 345191
Packit 345191
        for (int i=0; i
Packit 345191
            std::stringstream node;
Packit 345191
            node << "memory_overhad_node_" << i;
Packit 345191
            std::stringstream memory_overhead;
Packit 345191
            memory_overhead << stat.memory_overhead[i];
Packit 345191
            RecordProperty(node.str(), memory_overhead.str());
Packit 345191
        }
Packit 345191
    }
Packit 345191
Packit 345191
    AllocatorFactory allocator_factory;
Packit 345191
    float ref_time;
Packit 345191
};
Packit 345191
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_DEFAULT)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_DEFAULT);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_HBW)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HBW);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_INTERLEAVE)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_INTERLEAVE);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_HBW_INTERLEAVE)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HBW_INTERLEAVE);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_HBW_PREFERRED)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HBW_PREFERRED);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_HUGETLB)
Packit 345191
{
Packit 345191
    HugePageOrganizer huge_page_organizer(16);
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HUGETLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_GBTLB)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_GBTLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_libinit_HBW_HUGETLB)
Packit 345191
{
Packit 345191
    HugePageOrganizer huge_page_organizer(16);
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HBW_HUGETLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest,
Packit 345191
       test_TC_MEMKIND_perf_libinit_HBW_PREFERRED_HUGETLB)
Packit 345191
{
Packit 345191
    HugePageOrganizer huge_page_organizer(16);
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(
Packit 345191
            AllocatorTypes::MEMKIND_HBW_PREFERRED_HUGETLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest, test_TC_MEMKIND_perf_ext_libinit_HBW_GBTLB)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(AllocatorTypes::MEMKIND_HBW_GBTLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191
Packit 345191
TEST_F(HeapManagerInitPerfTest,
Packit 345191
       test_TC_MEMKIND_perf_libinit_HBW_PREFERRED_GBTLB)
Packit 345191
{
Packit 345191
    AllocatorFactory::initialization_stat stat =
Packit 345191
        allocator_factory.initialize_allocator(
Packit 345191
            AllocatorTypes::MEMKIND_HBW_PREFERRED_GBTLB);
Packit 345191
    post_test(stat);
Packit 345191
}
Packit 345191