You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
256 B
16 lines
256 B
|
3 years ago
|
package commonus
|
||
|
|
|
||
|
|
import "runtime"
|
||
|
|
|
||
|
|
//计算cpu合适数量
|
||
|
|
|
||
|
|
func CalculateTheNumberOfCPUCores() (int, bool) {
|
||
|
|
cpuNumber := runtime.NumCPU() - 3
|
||
|
|
cpuIsTrue := true
|
||
|
|
if cpuNumber <= 0 {
|
||
|
|
cpuNumber = 1
|
||
|
|
cpuIsTrue = false
|
||
|
|
}
|
||
|
|
return cpuNumber, cpuIsTrue
|
||
|
|
}
|