Skip to content

Commit c5c5040

Browse files
committed
sweet/benchmarks/internal/server: delete now-unused code
Change-Id: I5770f324363d8c02987e7f99164be9db91bc4f68 Reviewed-on: https://go-review.googlesource.com/c/benchmarks/+/600066 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
1 parent 24f05dc commit c5c5040

File tree

1 file changed

+0
-69
lines changed

1 file changed

+0
-69
lines changed

sweet/benchmarks/internal/server/server.go

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"io"
1212
"net/http"
1313
"os"
14-
"strings"
1514
"sync"
1615
"time"
1716

@@ -122,71 +121,3 @@ func collectTo(ctx context.Context, host string, diag *driver.Diagnostics, typ d
122121
}
123122
return err
124123
}
125-
126-
// TODO: Delete below here
127-
128-
func CollectDiagnostic(host, tmpDir, benchName string, typ diagnostics.Type) (int64, error) {
129-
// We attempt to use the benchmark name to create a temp file so replace all
130-
// path separators with "_".
131-
benchName = strings.Replace(benchName, "/", "_", -1)
132-
benchName = strings.Replace(benchName, string(os.PathSeparator), "_", -1)
133-
f, err := os.CreateTemp(tmpDir, benchName+"."+string(typ))
134-
if err != nil {
135-
return 0, err
136-
}
137-
defer f.Close()
138-
resp, err := http.Get(fmt.Sprintf("http://%s/debug/pprof/%s", host, endpoint(typ)))
139-
if err != nil {
140-
return 0, err
141-
}
142-
defer resp.Body.Close()
143-
n, err := io.Copy(f, resp.Body)
144-
if err != nil {
145-
return 0, err
146-
}
147-
return n, driver.CopyDiagnosticData(f.Name(), typ, benchName)
148-
}
149-
150-
func endpoint(typ diagnostics.Type) string {
151-
switch typ {
152-
case diagnostics.CPUProfile:
153-
return "profile?seconds=1"
154-
case diagnostics.MemProfile:
155-
return "heap"
156-
case diagnostics.Trace:
157-
return "trace?seconds=1"
158-
}
159-
panic("diagnostic " + string(typ) + " has no endpoint")
160-
}
161-
162-
func PollDiagnostic(host, tmpDir, benchName string, typ diagnostics.Type) (stop func() uint64) {
163-
// TODO(mknyszek): This is kind of a hack. We really should find a way to just
164-
// enable diagnostic collection at a lower level for the entire server run.
165-
var stopc chan struct{}
166-
var wg sync.WaitGroup
167-
var size uint64
168-
wg.Add(1)
169-
stopc = make(chan struct{})
170-
go func() {
171-
defer wg.Done()
172-
for {
173-
select {
174-
case <-stopc:
175-
return
176-
default:
177-
}
178-
n, err := CollectDiagnostic(host, tmpDir, benchName, typ)
179-
if err != nil {
180-
fmt.Fprintf(os.Stderr, "failed to read diagnostic %s: %v", typ, err)
181-
return
182-
}
183-
size += uint64(n)
184-
}
185-
}()
186-
return func() uint64 {
187-
// Stop the loop.
188-
close(stopc)
189-
wg.Wait()
190-
return size
191-
}
192-
}

0 commit comments

Comments
 (0)