diff options
Diffstat (limited to 'src/runtime/pprof/internal/protopprof/protopprof_test.go')
-rw-r--r-- | src/runtime/pprof/internal/protopprof/protopprof_test.go | 38 |
1 files changed, 0 insertions, 38 deletions
diff --git a/src/runtime/pprof/internal/protopprof/protopprof_test.go b/src/runtime/pprof/internal/protopprof/protopprof_test.go index beecefe04c..ad8b04bd37 100644 --- a/src/runtime/pprof/internal/protopprof/protopprof_test.go +++ b/src/runtime/pprof/internal/protopprof/protopprof_test.go @@ -8,37 +8,14 @@ import ( "bytes" "fmt" "internal/pprof/profile" - "io" "io/ioutil" "reflect" "runtime" - "runtime/pprof" "testing" "time" "unsafe" ) -// Profile collects a CPU utilization profile and -// writes it to w as a compressed profile.proto. It's used by -// TestProfileParse. -func Profile(w io.Writer, seconds int) error { - var buf bytes.Buffer - // Collect the CPU profile in legacy format in buf. - startTime := time.Now() - if err := pprof.StartCPUProfile(&buf); err != nil { - return fmt.Errorf("Could not enable CPU profiling: %s\n", err) - } - time.Sleep(time.Duration(seconds) * time.Second) - pprof.StopCPUProfile() - - const untagged = false - p, err := TranslateCPUProfile(buf.Bytes(), startTime) - if err != nil { - return err - } - return p.Write(w) -} - // Helper function to initialize empty cpu profile with sampling period provided. func createEmptyProfileWithPeriod(t *testing.T, periodMs uint64) bytes.Buffer { // Mock the sample header produced by cpu profiler. Write a sample @@ -85,21 +62,6 @@ func createProfileWithTwoSamples(t *testing.T, periodMs uintptr, count1 uintptr, return *buf } -// Tests that server creates a cpu profile handler that outputs a parsable Profile profile. -func TestCPUProfileParse(t *testing.T) { - var before, after runtime.MemStats - runtime.ReadMemStats(&before) - var buf bytes.Buffer - if err := Profile(&buf, 30); err != nil { - t.Fatalf("Profile failed: %v", err) - } - runtime.ReadMemStats(&after) - _, err := profile.Parse(&buf) - if err != nil { - t.Fatalf("Could not parse Profile profile: %v", err) - } -} - // Tests TranslateCPUProfile parses correct sampling period in an otherwise empty cpu profile. func TestTranlateCPUProfileSamplingPeriod(t *testing.T) { // A test server with mock cpu profile data. |