Path: blob/master/test/hotspot/gtest/gc/parallel/test_psAdaptiveSizePolicy.cpp
41149 views
/*1* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc/parallel/psAdaptiveSizePolicy.hpp"26#include "utilities/macros.hpp"27#include "unittest.hpp"2829#if INCLUDE_PARALLELGC3031TEST_VM(gc, oldFreeSpaceCalculation) {3233struct TestCase {34size_t live;35uintx ratio;36size_t expectedResult;37};3839TestCase test_cases[] = {40{100, 20, 25},41{100, 50, 100},42{100, 60, 150},43{100, 75, 300},44{400, 20, 100},45{400, 50, 400},46{400, 60, 600},47{400, 75, 1200},48};4950size_t array_len = sizeof(test_cases) / sizeof(TestCase);51for (size_t i = 0; i < array_len; ++i) {52ASSERT_EQ(PSAdaptiveSizePolicy::calculate_free_based_on_live(53test_cases[i].live, test_cases[i].ratio),54test_cases[i].expectedResult)55<< " Calculation of free memory failed"56<< " - Test case " << i << ": live = " << test_cases[i].live57<< "; ratio = " << test_cases[i].ratio;58}59}60#endif616263