@@ -18,7 +18,6 @@ import (
18
18
"runtime"
19
19
"strconv"
20
20
"strings"
21
- "sync/atomic"
22
21
23
22
clientv3 "go.etcd.io/etcd/client/v3"
24
23
"golang.org/x/benchmarks/sweet/benchmarks/internal/driver"
@@ -363,52 +362,24 @@ func run(cfg *config) (err error) {
363
362
return driver .RunBenchmark (cfg .bench .reportName , func (d * driver.B ) error {
364
363
// Set up diagnostics.
365
364
var stopAll par.Funcs
366
- if driver .DiagnosticEnabled (diagnostics .CPUProfile ) {
367
- for _ , inst := range instances {
368
- stop := server .PollDiagnostic (
369
- inst .host (clientPort ),
370
- cfg .tmpDir ,
371
- cfg .bench .reportName ,
372
- diagnostics .CPUProfile ,
373
- )
374
- stopAll .Add (stop )
375
- }
376
- }
377
- if driver .DiagnosticEnabled (diagnostics .Trace ) {
378
- var sum atomic.Uint64
379
- for _ , inst := range instances {
380
- stopTrace := server .PollDiagnostic (
381
- inst .host (clientPort ),
382
- cfg .tmpDir ,
383
- cfg .bench .reportName ,
384
- diagnostics .Trace ,
385
- )
386
- stopAll .Add (func () {
387
- n := stopTrace ()
388
- sum .Add (n )
389
- })
365
+ diag := driver .NewDiagnostics (cfg .bench .reportName )
366
+ for _ , typ := range diagnostics .Types () {
367
+ if typ .HTTPEndpoint () == "" {
368
+ continue
390
369
}
391
- defer func () {
392
- d .Report ("trace-bytes" , sum .Load ())
393
- }()
394
- }
395
- if driver .DiagnosticEnabled (diagnostics .MemProfile ) {
396
- for _ , inst := range instances {
397
- inst := inst
398
- stopAll .Add (func () {
399
- _ , err := server .CollectDiagnostic (
400
- inst .host (clientPort ),
401
- cfg .tmpDir ,
402
- cfg .bench .reportName ,
403
- diagnostics .MemProfile ,
404
- )
405
- if err != nil {
406
- fmt .Fprintf (os .Stderr , "failed to read memprofile: %v" , err )
407
- }
408
- })
370
+ for i , inst := range instances {
371
+ name := ""
372
+ if ! typ .CanMerge () {
373
+ // Create a separate file for each instance.
374
+ name = fmt .Sprintf ("inst%d" , i )
375
+ }
376
+ stop := server .FetchDiagnostic (inst .host (clientPort ), diag , typ , name )
377
+ stopAll .Add (stop )
409
378
}
410
379
}
380
+ defer diag .Commit (d )
411
381
defer stopAll .Run ()
382
+
412
383
// Actually run the benchmark.
413
384
return runBenchmark (d , cfg , instances )
414
385
}, opts ... )
0 commit comments