profiler: update busybench.go to allow specifying the number of busyworkers
This will allow us to use busybench in tests that we intend to add for validating that the agent respects server-specified backoffs
@@ -35,6 +35,7 @@ var (
duration = flag.Int("duration", 200, "duration of the benchmark in seconds")
apiAddr = flag.String("api_address", "", "API address of the profiler (e.g. 'cloudprofiler.googleapis.com:443')")
projectID = flag.String("project_id", "", "cloud project ID")
+ numBusyworkers = flag.Int("num_busyworkers", 20, "number of busyworkers to run in parallel")
)
// busywork continuously generates 1MiB of random data and compresses it
@@ -93,11 +94,10 @@ func main() {
var mu sync.Mutex
var wg sync.WaitGroup
- const numBusyworkers = 20
- wg.Add(numBusyworkers)
- runtime.GOMAXPROCS(numBusyworkers)
+ wg.Add(*numBusyworkers)
+ runtime.GOMAXPROCS(*numBusyworkers)
- for i := 0; i < numBusyworkers; i++ {
+ for i := 0; i < *numBusyworkers; i++ {
go func() {
defer wg.Done()
busywork(&mu)
