Skip to content

Commit

Permalink
sweet/benchmarks/internal/driver: delete now-unused diagnostics code
Browse files Browse the repository at this point in the history
Change-Id: Ie4376c70a17c718373064d30577b3afef0f5365b
Cq-Include-Trybots: luci.golang.try:x_benchmarks-gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/600070
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
  • Loading branch information
aclements committed Jul 29, 2024
1 parent c5c5040 commit af1e9c0
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 41 deletions.
40 changes: 0 additions & 40 deletions sweet/benchmarks/internal/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"sync"
"time"

"github.com/google/pprof/profile"
"golang.org/x/benchmarks/sweet/common/diagnostics"
)

Expand Down Expand Up @@ -575,49 +574,10 @@ func DiagnosticEnabled(typ diagnostics.Type) bool {
return ok
}

// TODO: Delete below here

func WritePprofProfile(prof *profile.Profile, typ diagnostics.Type, pattern string) error {
if !typ.IsPprof() {
return fmt.Errorf("this type of diagnostic doesn't use the pprof format")
}
if !DiagnosticEnabled(typ) {
return fmt.Errorf("this type of diagnostic is not currently enabled")
}
f, err := newDiagnosticDataFile(typ, pattern)
if err != nil {
return err
}
defer f.Close()
return prof.Write(f)
}

func CopyDiagnosticData(diagPath string, typ diagnostics.Type, pattern string) error {
inF, err := os.Open(diagPath)
if err != nil {
return err
}
defer inF.Close()
outF, err := newDiagnosticDataFile(typ, pattern)
if err != nil {
return err
}
defer outF.Close()
_, err = io.Copy(outF, inF)
return err
}

func PerfFlags() []string {
cfg, ok := diag.ConfigSet.Get(diagnostics.Perf)
if !ok {
panic("perf not enabled")
}
return strings.Split(cfg.Flags, " ")
}

func newDiagnosticDataFile(typ diagnostics.Type, pattern string) (*os.File, error) {
if !DiagnosticEnabled(typ) {
return nil, fmt.Errorf("this type of profile is not currently enabled")
}
return os.CreateTemp(diag.ResultsDir, pattern+"."+string(typ))
}
2 changes: 1 addition & 1 deletion sweet/cmd/sweet/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ func (c *runCmd) preparePGO(configs []*common.Config, benchmarks []*benchmark) (
return newConfigs, nil
}

var cpuProfileRe = regexp.MustCompile(`\.cpuprofile[0-9]+|-cpu\.prof$`)
var cpuProfileRe = regexp.MustCompile(`-cpu\.prof$`)

func mergeCPUProfiles(dir string) (string, error) {
profiles, err := sprofile.ReadDirPprof(dir, func(name string) bool {
Expand Down

0 comments on commit af1e9c0

Please sign in to comment.