Skip to content

Instantly share code, notes, and snippets.

@mrichman
Created July 17, 2018 12:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrichman/e07725686b20e56496dc53ead441fc63 to your computer and use it in GitHub Desktop.
Save mrichman/e07725686b20e56496dc53ead441fc63 to your computer and use it in GitHub Desktop.
Beat up your CPU for 10 seconds
package main
import (
"runtime"
"time"
)
func main() {
n := runtime.NumCPU()
runtime.GOMAXPROCS(n)
quit := make(chan bool)
for i := 0; i < n; i++ {
go func() {
for {
select {
case <-quit:
return
default:
}
}
}()
}
time.Sleep(10 * time.Second)
for i := 0; i < n; i++ {
quit <- true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment