| 1 | // Copyright 2014 Google Inc. All Rights Reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ |
| 16 | |
| 17 | import ( |
| 18 | "bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/" |
| 19 | "fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/" |
| 20 | "osscip-go gomod github.com/golang/go/src go1.24.0 os/" |
| 21 | "path/filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/" |
| 22 | "regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/" |
| 23 | "runtimescip-go gomod github.com/golang/go/src go1.24.0 runtime/" |
| 24 | "slicesscip-go gomod github.com/golang/go/src go1.24.0 slices/" |
| 25 | "stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/" |
| 26 | "testingscip-go gomod github.com/golang/go/src go1.24.0 testing/" |
| 27 | "timescip-go gomod github.com/golang/go/src go1.24.0 time/" |
| 28 | |
| 29 | "github.com/google/pprof/internal/binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/" |
| 30 | "github.com/google/pprof/internal/graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/" |
| 31 | "github.com/google/pprof/internal/proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/" |
| 32 | "github.com/google/pprof/profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/" |
| 33 | ) |
| 34 | |
| 35 | type testcasescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase# struct { |
| 36 | rptscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#rpt. *Reportscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report# |
| 37 | wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want. string |
| 38 | } |
| 39 | |
| 40 | func TestSourcescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestSource().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 41 | const path = "testdata/" |
| 42 | |
| 43 | sampleValue1 := func(v []int64) int64 { |
| 44 | return v[1] |
| 45 | } |
| 46 | |
| 47 | for _, tc := range []testcasescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#{ |
| 48 | { |
| 49 | rptscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#rpt.: Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().( |
| 50 | testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().(), |
| 51 | &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 52 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List., |
| 53 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`.`), |
| 54 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath.: "/some/path", |
| 55 | |
| 56 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: sampleValue1, |
| 57 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 58 | }, |
| 59 | ), |
| 60 | wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want.: path + "source.rpt", |
| 61 | }, |
| 62 | { |
| 63 | rptscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#rpt.: Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().( |
| 64 | testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().(), |
| 65 | &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 66 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot., |
| 67 | CallTreescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#CallTree.: true, |
| 68 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`.`), |
| 69 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath.: "/some/path", |
| 70 | |
| 71 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: sampleValue1, |
| 72 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 73 | }, |
| 74 | ), |
| 75 | wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want.: path + "source.dot", |
| 76 | }, |
| 77 | } { |
| 78 | var b bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer# |
| 79 | if err := Generatescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Generate().(&b, tc.rptscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#rpt., &binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/.Binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/Binutils#{}); err != nil { |
| 80 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("%s: %v", tc.wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want., err) |
| 81 | } |
| 82 | |
| 83 | gold, err := osscip-go gomod github.com/golang/go/src go1.24.0 os/.ReadFilescip-go gomod github.com/golang/go/src go1.24.0 os/ReadFile().(tc.wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want.) |
| 84 | if err != nil { |
| 85 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("%s: %v", tc.wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want., err) |
| 86 | } |
| 87 | if runtimescip-go gomod github.com/golang/go/src go1.24.0 runtime/.GOOSscip-go gomod github.com/golang/go/src go1.24.0 runtime/GOOS. == "windows" { |
| 88 | if tc.rptscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#rpt..optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#options..OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat. == Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot. { |
| 89 | // The .dot test has the paths inside strings, so \ must be escaped. |
| 90 | gold = bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 bytes/ReplaceAll().(gold, []byte("testdata/"), []byte(`testdata\\`)) |
| 91 | } else { |
| 92 | gold = bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.ReplaceAllscip-go gomod github.com/golang/go/src go1.24.0 bytes/ReplaceAll().(gold, []byte("testdata/"), []byte(`testdata\`)) |
| 93 | } |
| 94 | } |
| 95 | if string(b.Stringscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#String().()) != string(gold) { |
| 96 | d, err := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.Diffscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/Diff().(gold, b.Bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#Bytes().()) |
| 97 | if err != nil { |
| 98 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("%s: %v", "source", err) |
| 99 | } |
| 100 | t.Errorscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Error().("source" + "\n" + string(d) + "\n" + "gold:\n" + tc.wantscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testcase#want.) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | |
| 105 | // TestFilter ensures that commands with a regexp filter argument return an |
| 106 | // error if there are no results. |
| 107 | func TestFilterscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestFilter().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 108 | const filter = "doesNotExist" |
| 109 | |
| 110 | tests := []struct { |
| 111 | name string |
| 112 | format int |
| 113 | }{ |
| 114 | { |
| 115 | name: "list", |
| 116 | format: Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List., |
| 117 | }, |
| 118 | { |
| 119 | name: "disasm", |
| 120 | format: Disscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dis., |
| 121 | }, |
| 122 | { |
| 123 | // N.B. Tree with a Symbol is "peek". |
| 124 | name: "peek", |
| 125 | format: Treescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Tree., |
| 126 | }, |
| 127 | } |
| 128 | for _, tc := range tests { |
| 129 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 130 | rpt := Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().(), &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 131 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: tc.format, |
| 132 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(filter), |
| 133 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: func(v []int64) int64 { return v[1] }, |
| 134 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 135 | }) |
| 136 | |
| 137 | var buf bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.Bufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer# |
| 138 | err := Generatescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Generate().(&buf, rpt, &binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/.Binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/Binutils#{}) |
| 139 | if err == nil { |
| 140 | t.Fatalfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatalf().("Generate got nil, want error; buf = %s", buf.Stringscip-go gomod github.com/golang/go/src go1.24.0 bytes/Buffer#String().()) |
| 141 | } |
| 142 | if !stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.24.0 strings/Contains().(err.Error(), filter) { |
| 143 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("Error got %v, want it to contain %q", err, filter) |
| 144 | } |
| 145 | }) |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | // testM contains mappings for fake profiles used in tests. |
| 150 | var testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#{ |
| 151 | { |
| 152 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#ID.: 1, |
| 153 | HasFunctionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFunctions.: true, |
| 154 | HasFilenamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasFilenames.: true, |
| 155 | HasLineNumbersscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasLineNumbers.: true, |
| 156 | HasInlineFramesscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Mapping#HasInlineFrames.: true, |
| 157 | }, |
| 158 | } |
| 159 | |
| 160 | // testF contains functions for fake profiles used in tests. |
| 161 | var testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{ |
| 162 | { |
| 163 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 1, |
| 164 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "main", |
| 165 | Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "testdata/source1", |
| 166 | }, |
| 167 | { |
| 168 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 2, |
| 169 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "foo", |
| 170 | Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "testdata/source1", |
| 171 | }, |
| 172 | { |
| 173 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 3, |
| 174 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "bar", |
| 175 | Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "testdata/source1", |
| 176 | }, |
| 177 | { |
| 178 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 4, |
| 179 | Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "tee", |
| 180 | Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "/some/path/testdata/source2", |
| 181 | }, |
| 182 | } |
| 183 | |
| 184 | // testL contains locations for fake profiles used in tests. |
| 185 | var testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{ |
| 186 | { |
| 187 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 1, |
| 188 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 189 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 190 | { |
| 191 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[0], |
| 192 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 2, |
| 193 | Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column.: 2, |
| 194 | }, |
| 195 | }, |
| 196 | }, |
| 197 | { |
| 198 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 2, |
| 199 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 200 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 201 | { |
| 202 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[1], |
| 203 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 4, |
| 204 | Columnscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Column.: 4, |
| 205 | }, |
| 206 | }, |
| 207 | }, |
| 208 | { |
| 209 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 3, |
| 210 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 211 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 212 | { |
| 213 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[2], |
| 214 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 10, |
| 215 | }, |
| 216 | }, |
| 217 | }, |
| 218 | { |
| 219 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 4, |
| 220 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 221 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 222 | { |
| 223 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[3], |
| 224 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 2, |
| 225 | }, |
| 226 | }, |
| 227 | }, |
| 228 | { |
| 229 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 5, |
| 230 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 231 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 232 | { |
| 233 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[3], |
| 234 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 8, |
| 235 | }, |
| 236 | }, |
| 237 | }, |
| 238 | { |
| 239 | IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#ID.: 6, |
| 240 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM.[0], |
| 241 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#Line.: []profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#{ |
| 242 | { |
| 243 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[3], |
| 244 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 7, |
| 245 | }, |
| 246 | { |
| 247 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF.[2], |
| 248 | Linescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Line#Line.: 6, |
| 249 | }, |
| 250 | }, |
| 251 | }, |
| 252 | } |
| 253 | |
| 254 | // testSample returns a profile sample with specified value and stack. |
| 255 | // Note: callees come first in sample stacks. |
| 256 | func testSamplescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testSample().(value int64, locs ...*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#) *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample# { |
| 257 | return &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 258 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{value}, |
| 259 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: locs, |
| 260 | } |
| 261 | } |
| 262 | |
| 263 | // makeTestProfile returns a profile with specified samples that uses testL/testF/testM |
| 264 | // (defined in report_test.go). |
| 265 | func makeTestProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/makeTestProfile().(samples ...*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#) *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# { |
| 266 | return &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 267 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "samples", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "count"}}, |
| 268 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: samples, |
| 269 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.: testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL., |
| 270 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF., |
| 271 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM., |
| 272 | } |
| 273 | } |
| 274 | |
| 275 | // testProfile contains a fake profile used in tests. |
| 276 | // Various report methods modify profiles so tests should operate on testProfile.Copy(). |
| 277 | var testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile. = &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#{ |
| 278 | PeriodTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#PeriodType.: &profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "millisecond"}, |
| 279 | Periodscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Period.: 10, |
| 280 | DurationNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DurationNanos.: 10e9, |
| 281 | SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.ValueTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#{ |
| 282 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "samples", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "count"}, |
| 283 | {Typescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Type.: "cpu", Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit.: "cycles"}, |
| 284 | }, |
| 285 | Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 286 | { |
| 287 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 288 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 1}, |
| 289 | }, |
| 290 | { |
| 291 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 292 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 10}, |
| 293 | }, |
| 294 | { |
| 295 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[4], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 296 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 100}, |
| 297 | }, |
| 298 | { |
| 299 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[3], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 300 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 1000}, |
| 301 | }, |
| 302 | { |
| 303 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[4], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[3], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 304 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 10000}, |
| 305 | }, |
| 306 | }, |
| 307 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Location.: testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL., |
| 308 | Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Function.: testFscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testF., |
| 309 | Mappingscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Mapping.: testMscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testM., |
| 310 | } |
| 311 | |
| 312 | func TestDisambiguationscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestDisambiguation().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 313 | parent1 := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "parent1"}} |
| 314 | parent2 := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "parent2"}} |
| 315 | child1 := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "child"}, Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.: parent1} |
| 316 | child2 := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "child"}, Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.: parent2} |
| 317 | child3 := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "child"}, Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.: parent1} |
| 318 | sibling := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info.: graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "sibling"}, Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Function.: parent1} |
| 319 | |
| 320 | n := []*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#{parent1, parent2, child1, child2, child3, sibling} |
| 321 | |
| 322 | wanted := map[*graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Nodescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#]string{ |
| 323 | parent1: "parent1", |
| 324 | parent2: "parent2", |
| 325 | child1: "child [1/2]", |
| 326 | child2: "child [2/2]", |
| 327 | child3: "child [1/2]", |
| 328 | sibling: "sibling", |
| 329 | } |
| 330 | |
| 331 | g := &graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.Graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#{Nodesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Graph#Nodes.: n} |
| 332 | |
| 333 | names := getDisambiguatedNamesscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/getDisambiguatedNames().(g) |
| 334 | |
| 335 | for node, want := range wanted { |
| 336 | if got := names[node]; got != want { |
| 337 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("name %s, got %s, want %s", node.Infoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/Node#Info..Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name., got, want) |
| 338 | } |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | func TestFunctionMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestFunctionMap().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 343 | |
| 344 | fm := make(functionMapscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#) |
| 345 | nodes := []graphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/.NodeInfoscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#{ |
| 346 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "fun1"}, |
| 347 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "fun2", Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.: "filename"}, |
| 348 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "fun1"}, |
| 349 | {Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#Name.: "fun2", Filescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/graph`/NodeInfo#File.: "filename2"}, |
| 350 | } |
| 351 | |
| 352 | want := []struct { |
| 353 | wantFunction profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function# |
| 354 | wantAdded bool |
| 355 | }{ |
| 356 | {profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 1, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun1"}, true}, |
| 357 | {profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 2, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun2", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "filename"}, true}, |
| 358 | {profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 1, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun1"}, false}, |
| 359 | {profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Functionscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#{IDscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#ID.: 3, Namescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Name.: "fun2", Filenamescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Function#Filename.: "filename2"}, true}, |
| 360 | } |
| 361 | |
| 362 | for i, tc := range nodes { |
| 363 | gotFunc, gotAdded := fm.findOrAddscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/functionMap#findOrAdd().(tc) |
| 364 | if got, want := gotFunc, want[i].wantFunction; *got != want { |
| 365 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%d: got %v, want %v", i, got, want) |
| 366 | } |
| 367 | if got, want := gotAdded, want[i].wantAdded; got != want { |
| 368 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%d: got %v, want %v", i, got, want) |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | func TestLegendActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestLegendActiveFilters().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 374 | activeFilterInput := []string{ |
| 375 | "focus=123|456|789|101112|131415|161718|192021|222324|252627|282930|313233|343536|363738|acbdefghijklmnop", |
| 376 | "show=short filter", |
| 377 | } |
| 378 | expectedLegendActiveFilter := []string{ |
| 379 | "Active filters:", |
| 380 | " focus=123|456|789|101112|131415|161718|192021|222324|252627|282930|313233|343536…", |
| 381 | " show=short filter", |
| 382 | } |
| 383 | legendActiveFilter := legendActiveFiltersscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/legendActiveFilters().(activeFilterInput) |
| 384 | if len(legendActiveFilter) != len(expectedLegendActiveFilter) { |
| 385 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("wanted length %v got length %v", len(expectedLegendActiveFilter), len(legendActiveFilter)) |
| 386 | } |
| 387 | for i := range legendActiveFilter { |
| 388 | if legendActiveFilter[i] != expectedLegendActiveFilter[i] { |
| 389 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("%d: want \"%v\", got \"%v\"", i, expectedLegendActiveFilter[i], legendActiveFilter[i]) |
| 390 | } |
| 391 | } |
| 392 | } |
| 393 | |
| 394 | func TestComputeTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestComputeTotal().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 395 | p1 := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 396 | p1.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 397 | { |
| 398 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 399 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 1}, |
| 400 | }, |
| 401 | { |
| 402 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 403 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 10}, |
| 404 | }, |
| 405 | { |
| 406 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[4], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 407 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 100}, |
| 408 | }, |
| 409 | } |
| 410 | |
| 411 | p2 := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 412 | p2.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 413 | { |
| 414 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 415 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 1}, |
| 416 | }, |
| 417 | { |
| 418 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 419 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, -10}, |
| 420 | }, |
| 421 | { |
| 422 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[4], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 423 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1, 100}, |
| 424 | }, |
| 425 | } |
| 426 | |
| 427 | p3 := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 428 | p3.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Sample. = []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Samplescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#{ |
| 429 | { |
| 430 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 431 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{10000, 1}, |
| 432 | }, |
| 433 | { |
| 434 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 435 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{-10, 3}, |
| 436 | Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.: map[string][]string{"pprof::base": {"true"}}, |
| 437 | }, |
| 438 | { |
| 439 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 440 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{1000, -10}, |
| 441 | }, |
| 442 | { |
| 443 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 444 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{-9000, 3}, |
| 445 | Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.: map[string][]string{"pprof::base": {"true"}}, |
| 446 | }, |
| 447 | { |
| 448 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 449 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{-1, 3}, |
| 450 | Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.: map[string][]string{"pprof::base": {"true"}}, |
| 451 | }, |
| 452 | { |
| 453 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[4], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 454 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{100, 100}, |
| 455 | }, |
| 456 | { |
| 457 | Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Location.: []*profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Locationscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Location#{testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[2], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[1], testLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testL.[0]}, |
| 458 | Valuescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Value.: []int64{100, 3}, |
| 459 | Labelscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Sample#Label.: map[string][]string{"pprof::base": {"true"}}, |
| 460 | }, |
| 461 | } |
| 462 | |
| 463 | testcases := []struct { |
| 464 | desc string |
| 465 | prof *profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile# |
| 466 | value, meanDiv func(v []int64) int64 |
| 467 | wantTotal int64 |
| 468 | }{ |
| 469 | { |
| 470 | desc: "no diff base, all positive values, index 1", |
| 471 | prof: p1, |
| 472 | value: func(v []int64) int64 { |
| 473 | return v[0] |
| 474 | }, |
| 475 | wantTotal: 3, |
| 476 | }, |
| 477 | { |
| 478 | desc: "no diff base, all positive values, index 2", |
| 479 | prof: p1, |
| 480 | value: func(v []int64) int64 { |
| 481 | return v[1] |
| 482 | }, |
| 483 | wantTotal: 111, |
| 484 | }, |
| 485 | { |
| 486 | desc: "no diff base, some negative values", |
| 487 | prof: p2, |
| 488 | value: func(v []int64) int64 { |
| 489 | return v[1] |
| 490 | }, |
| 491 | wantTotal: 111, |
| 492 | }, |
| 493 | { |
| 494 | desc: "diff base, some negative values", |
| 495 | prof: p3, |
| 496 | value: func(v []int64) int64 { |
| 497 | return v[0] |
| 498 | }, |
| 499 | wantTotal: 9111, |
| 500 | }, |
| 501 | } |
| 502 | |
| 503 | for _, tc := range testcases { |
| 504 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(tc.desc, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 505 | if gotTotal := computeTotalscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/computeTotal().(tc.prof, tc.value, tc.meanDiv); gotTotal != tc.wantTotal { |
| 506 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("got total %d, want %v", gotTotal, tc.wantTotal) |
| 507 | } |
| 508 | }) |
| 509 | } |
| 510 | } |
| 511 | |
| 512 | func TestPrintAssemblyErrorMessagescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestPrintAssemblyErrorMessage().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 513 | profile := readProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/readProfile().(filepathscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/.Joinscip-go gomod github.com/golang/go/src go1.24.0 `path/filepath`/Join().("testdata", "sample.cpu"), t) |
| 514 | |
| 515 | for _, tc := range []struct { |
| 516 | desc string |
| 517 | symbol string |
| 518 | want string |
| 519 | }{ |
| 520 | { |
| 521 | desc: "no matched symbol in binary", |
| 522 | symbol: "symbol-not-exist", |
| 523 | want: "no matches found for regexp symbol-not-exist", |
| 524 | }, |
| 525 | { |
| 526 | desc: "no matched address in binary", |
| 527 | symbol: "0xffffaaaa", |
| 528 | want: "no matches found for address 0xffffaaaa", |
| 529 | }, |
| 530 | { |
| 531 | desc: "matched address in binary but not in the profile", |
| 532 | symbol: "0x400000", |
| 533 | want: "address 0x400000 found in binary, but the corresponding symbols do not have samples in the profile", |
| 534 | }, |
| 535 | } { |
| 536 | rpt := Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().( |
| 537 | profile.Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().(), |
| 538 | &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 539 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: Listscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/List., |
| 540 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(tc.symbol), |
| 541 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: func(v []int64) int64 { |
| 542 | return v[1] |
| 543 | }, |
| 544 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: profile.SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 545 | }, |
| 546 | ) |
| 547 | |
| 548 | if err := PrintAssemblyscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/PrintAssembly().(osscip-go gomod github.com/golang/go/src go1.24.0 os/.Stdoutscip-go gomod github.com/golang/go/src go1.24.0 os/Stdout., rpt, &binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/.Binutilsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/binutils`/Binutils#{}, -1); err == nil || err.Error() != tc.want { |
| 549 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().(`Got "%v", want %q`, err, tc.want) |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | func TestDocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestDocURL().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 555 | type testCase struct { |
| 556 | input string |
| 557 | want string |
| 558 | } |
| 559 | for name, c := range map[string]testCase{ |
| 560 | "empty": {"", ""}, |
| 561 | "http": {"http://example.com/pprof-help", "http://example.com/pprof-help"}, |
| 562 | "https": {"https://example.com/pprof-help", "https://example.com/pprof-help"}, |
| 563 | "relative": {"/foo", ""}, |
| 564 | "nonhttp": {"mailto:[email protected]", ""}, |
| 565 | } { |
| 566 | t.Runscip-go gomod github.com/golang/go/src go1.24.0 testing/T#Run().(name, func(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 567 | profile := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 568 | profile.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL. = c.input |
| 569 | rpt := Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(profile, &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 570 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: Dotscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Dot., |
| 571 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`.`), |
| 572 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath.: "/some/path", |
| 573 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: func(v []int64) int64 { return v[1] }, |
| 574 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 575 | }) |
| 576 | if got := rpt.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#DocURL().(); got != c.want { |
| 577 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("bad doc URL %q, expecting %q", got, c.want) |
| 578 | } |
| 579 | }) |
| 580 | } |
| 581 | } |
| 582 | |
| 583 | func TestDocURLInLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestDocURLInLabels().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 584 | const url = "http://example.com/pprof-help" |
| 585 | profile := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 586 | profile.DocURLscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#DocURL. = url |
| 587 | rpt := Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(profile, &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 588 | OutputFormatscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#OutputFormat.: Textscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Text., |
| 589 | Symbolscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#Symbol.: regexpscip-go gomod github.com/golang/go/src go1.24.0 regexp/.MustCompilescip-go gomod github.com/golang/go/src go1.24.0 regexp/MustCompile().(`.`), |
| 590 | TrimPathscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#TrimPath.: "/some/path", |
| 591 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: func(v []int64) int64 { return v[1] }, |
| 592 | SampleUnitscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleUnit.: testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..SampleTypescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#SampleType.[1].Unitscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/ValueType#Unit., |
| 593 | }) |
| 594 | |
| 595 | labels := fmtscip-go gomod github.com/golang/go/src go1.24.0 fmt/.Sprintfscip-go gomod github.com/golang/go/src go1.24.0 fmt/Sprintf().("%v", ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ProfileLabels().(rpt)) |
| 596 | if !stringsscip-go gomod github.com/golang/go/src go1.24.0 strings/.Containsscip-go gomod github.com/golang/go/src go1.24.0 strings/Contains().(labels, url) { |
| 597 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("expected URL %q not found in %s", url, labels) |
| 598 | } |
| 599 | } |
| 600 | |
| 601 | func TestProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/TestProfileLabels().(t *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Tscip-go gomod github.com/golang/go/src go1.24.0 testing/T#) { |
| 602 | // Force the local timezone to UTC for the duration of this function to get a |
| 603 | // predictable result out of timezone printing. |
| 604 | defer func(prev *timescip-go gomod github.com/golang/go/src go1.24.0 time/.Locationscip-go gomod github.com/golang/go/src go1.24.0 time/Location#) { timescip-go gomod github.com/golang/go/src go1.24.0 time/.Localscip-go gomod github.com/golang/go/src go1.24.0 time/Local. = prev }(timescip-go gomod github.com/golang/go/src go1.24.0 time/.Localscip-go gomod github.com/golang/go/src go1.24.0 time/Local.) |
| 605 | timescip-go gomod github.com/golang/go/src go1.24.0 time/.Localscip-go gomod github.com/golang/go/src go1.24.0 time/Local. = timescip-go gomod github.com/golang/go/src go1.24.0 time/.UTCscip-go gomod github.com/golang/go/src go1.24.0 time/UTC. |
| 606 | |
| 607 | profile := testProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/testProfile..Copyscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#Copy().() |
| 608 | profile.TimeNanosscip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Profile#TimeNanos. = timescip-go gomod github.com/golang/go/src go1.24.0 time/.Unixscip-go gomod github.com/golang/go/src go1.24.0 time/Unix().(131, 0).UnixNanoscip-go gomod github.com/golang/go/src go1.24.0 time/Time#UnixNano().() |
| 609 | rpt := Newscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/New().(profile, &Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{ |
| 610 | SampleValuescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#SampleValue.: func(v []int64) int64 { return v[1] }, |
| 611 | }) |
| 612 | |
| 613 | const want = "Time: 1970-01-01 00:02:11 UTC" |
| 614 | if labels := ProfileLabelsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/ProfileLabels().(rpt); !slicesscip-go gomod github.com/golang/go/src go1.24.0 slices/.Containsscip-go gomod github.com/golang/go/src go1.24.0 slices/Contains().(labels, want) { |
| 615 | t.Errorfscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Errorf().("wanted to find a label containing %q, but found none in %v", want, labels) |
| 616 | } |
| 617 | } |
| 618 | |
| 619 | func BenchmarkReportNewTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/BenchmarkReportNewTrimmedGraph().(b *testingscip-go gomod github.com/golang/go/src go1.24.0 testing/.Bscip-go gomod github.com/golang/go/src go1.24.0 testing/B#) { |
| 620 | data := proftestscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/.LargeProfilescip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/proftest`/LargeProfile().(b) |
| 621 | prof, err := profilescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/.Parsescip-go gomod github.com/google/pprof . `github.com/google/pprof/profile`/Parse().(bytesscip-go gomod github.com/golang/go/src go1.24.0 bytes/.NewBufferscip-go gomod github.com/golang/go/src go1.24.0 bytes/NewBuffer().(data)) |
| 622 | if err != nil { |
| 623 | b.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().(err) |
| 624 | } |
| 625 | rep := NewDefaultscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/NewDefault().(prof, Optionsscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Options#{}) |
| 626 | |
| 627 | b.ReportAllocsscip-go gomod github.com/golang/go/src go1.24.0 testing/B#ReportAllocs().() |
| 628 | b.ResetTimerscip-go gomod github.com/golang/go/src go1.24.0 testing/B#ResetTimer().() |
| 629 | for i := 0; i < b.Nscip-go gomod github.com/golang/go/src go1.24.0 testing/B#N.; i++ { |
| 630 | g, _, _, _ := rep.newTrimmedGraphscip-go gomod github.com/google/pprof . `github.com/google/pprof/internal/report`/Report#newTrimmedGraph().() |
| 631 | if g == nil { |
| 632 | b.Fatalscip-go gomod github.com/golang/go/src go1.24.0 testing/common#Fatal().("empty graph") |
| 633 | } |
| 634 | } |
| 635 | } |