1*635a8641SAndroid Build Coastguard Worker // Copyright 2016 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker #include "base/task_scheduler/initialization_util.h" 6*635a8641SAndroid Build Coastguard Worker 7*635a8641SAndroid Build Coastguard Worker #include <algorithm> 8*635a8641SAndroid Build Coastguard Worker 9*635a8641SAndroid Build Coastguard Worker #include "base/sys_info.h" 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard Worker namespace base { 12*635a8641SAndroid Build Coastguard Worker RecommendedMaxNumberOfThreadsInPool(int min,int max,double cores_multiplier,int offset)13*635a8641SAndroid Build Coastguard Workerint RecommendedMaxNumberOfThreadsInPool(int min, 14*635a8641SAndroid Build Coastguard Worker int max, 15*635a8641SAndroid Build Coastguard Worker double cores_multiplier, 16*635a8641SAndroid Build Coastguard Worker int offset) { 17*635a8641SAndroid Build Coastguard Worker const int num_of_cores = SysInfo::NumberOfProcessors(); 18*635a8641SAndroid Build Coastguard Worker const int threads = std::ceil<int>(num_of_cores * cores_multiplier) + offset; 19*635a8641SAndroid Build Coastguard Worker return std::min(max, std::max(min, threads)); 20*635a8641SAndroid Build Coastguard Worker } 21*635a8641SAndroid Build Coastguard Worker 22*635a8641SAndroid Build Coastguard Worker } // namespace base 23