MCPcopy Create free account
hub / github.com/google/pprof / TestFilterSamplesByName

Function TestFilterSamplesByName

profile/filter_test.go:126–415  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

124}
125
126func TestFilterSamplesByName(t *testing.T) {
127 for _, tc := range []struct {
128 // name is the name of the test case.
129 name string
130 // profile is the profile that gets filtered.
131 profile *Profile
132 // These are the inputs to FilterSamplesByName().
133 focus, ignore, hide, show *regexp.Regexp
134 // want{F,I,S,H}m are expected return values from FilterSamplesByName.
135 wantFm, wantIm, wantSm, wantHm bool
136 // wantSampleFuncs contains expected stack functions and sample value after
137 // filtering, in the same order as in the profile. The format is as
138 // returned by sampleFuncs function below, which is "callee caller: <num>".
139 wantSampleFuncs []string
140 }{
141 // No Filters
142 {
143 name: "empty filters keep all frames",
144 profile: noInlinesProfile,
145 wantFm: true,
146 wantSampleFuncs: allNoInlinesSampleFuncs,
147 },
148 // Focus
149 {
150 name: "focus with no matches",
151 profile: noInlinesProfile,
152 focus: regexp.MustCompile("unknown"),
153 },
154 {
155 name: "focus matches function names",
156 profile: noInlinesProfile,
157 focus: regexp.MustCompile("fun1"),
158 wantFm: true,
159 wantSampleFuncs: []string{
160 "fun0 fun1 fun2 fun3: 1",
161 "fun4 fun5 fun1 fun6: 2",
162 "fun9 fun4 fun10 fun7: 4",
163 },
164 },
165 {
166 name: "focus matches file names",
167 profile: noInlinesProfile,
168 focus: regexp.MustCompile("file1"),
169 wantFm: true,
170 wantSampleFuncs: []string{
171 "fun0 fun1 fun2 fun3: 1",
172 "fun4 fun5 fun1 fun6: 2",
173 "fun9 fun4 fun10 fun7: 4",
174 },
175 },
176 {
177 name: "focus matches mapping names",
178 profile: noInlinesProfile,
179 focus: regexp.MustCompile("map1"),
180 wantFm: true,
181 wantSampleFuncs: []string{
182 "fun9 fun4 fun10 fun7: 4",
183 },

Callers

nothing calls this directly

Calls 4

DiffFunction · 0.92
sampleFuncsFunction · 0.85
CopyMethod · 0.80
FilterSamplesByNameMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…