Commit 2aad0793 authored by Kirill Smelkov's avatar Kirill Smelkov Committed by Kirill Smelkov

cpuburn: Utility to load all cores

Debian's cpuburn was removed from the distribution.
parent 563a6128
// #!/usr/bin/env -S go run
// cpuburn loads all cpu cores.
//
// Reason for this program: cpuburn Debian package got bitrotted.
//
// Note: one can also simulate 1 core burn by `yes >/dev/null`.
package main
import (
"runtime"
"sync"
)
func work() {
var i [3]int
var x [3]float64
i[0], i[1], i[2] = 1, 2, 3
x[0], x[1], x[2] = 3.14, 2.17, 1.61
for j := 0; ; j++ {
// ALU
kp := j % 3
k := (kp+1) % 3
// FPU
x[k] += float64(i[kp]) * x[kp]
}
}
func main() {
wg := sync.WaitGroup{}
njob := runtime.NumCPU()
for i := 0; i < njob; i++ {
wg.Add(1)
go func() {
defer wg.Done()
work()
}()
}
wg.Wait()
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment