package runtimebench import ( "crypto/sha256" "testing" "time" ) // Run with -cpu=1,4. Both workloads use the same parallel driver; one consumes // execution time, the other parks awaiting a timer (a controlled wait, not a network benchmark). func BenchmarkWork(b *testing.B) { for _, kind := range []string{"cpu", "wait"} { b.Run(kind, func(b *testing.B) { b.RunParallel(func(pb *testing.PB) { var sum [32]byte for pb.Next() { if kind == "cpu" { for range 1024 { sum = sha256.Sum256(sum[:]) } } else { time.Sleep(time.Millisecond) } } }) }) } }