Created
June 24, 2013 07:25
-
-
Save peterhellberg/5848304 to your computer and use it in GitHub Desktop.
Find out the max value for GOMAXPROCS on your machine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"runtime" | |
) | |
func MaxParallelism() int { | |
maxProcs := runtime.GOMAXPROCS(0) | |
numCPU := runtime.NumCPU() | |
if maxProcs < numCPU { | |
return maxProcs | |
} | |
return numCPU | |
} | |
func main() { | |
fmt.Println("MaxParallelism: ", MaxParallelism()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The result on my MacBook Air:
On the Raspberry Pi (Cross-compiled using
GOARCH=arm GOARM=5 GOOS=linux go build max_parallelism.go
)