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

Function makeFakeProfile

browsertests/testutils.go:105–159  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

103}
104
105func makeFakeProfile() *profile.Profile {
106 // Three functions: F1, F2, F3 with three lines, 11, 22, 33.
107 funcs := []*profile.Function{
108 {ID: 1, Name: "F1", Filename: fakeSource, StartLine: 3},
109 {ID: 2, Name: "F2", Filename: fakeSource, StartLine: 5},
110 {ID: 3, Name: "F3", Filename: fakeSource, StartLine: 7},
111 }
112 lines := []profile.Line{
113 {Function: funcs[0], Line: 11},
114 {Function: funcs[1], Line: 22},
115 {Function: funcs[2], Line: 33},
116 }
117 mapping := []*profile.Mapping{
118 {
119 ID: 1,
120 Start: addrBase,
121 Limit: addrBase + 100,
122 Offset: 0,
123 File: "testbin",
124 HasFunctions: true,
125 HasFilenames: true,
126 HasLineNumbers: true,
127 },
128 }
129
130 // Three interesting addresses: base+{10,20,30}
131 locs := []*profile.Location{
132 {ID: 1, Address: addrBase + 10, Line: lines[0:1], Mapping: mapping[0]},
133 {ID: 2, Address: addrBase + 20, Line: lines[1:2], Mapping: mapping[0]},
134 {ID: 3, Address: addrBase + 30, Line: lines[2:3], Mapping: mapping[0]},
135 }
136
137 // Two stack traces.
138 return &profile.Profile{
139 PeriodType: &profile.ValueType{Type: "cpu", Unit: "milliseconds"},
140 Period: 1,
141 DurationNanos: 10e9,
142 SampleType: []*profile.ValueType{
143 {Type: "cpu", Unit: "milliseconds"},
144 },
145 Sample: []*profile.Sample{
146 {
147 Location: []*profile.Location{locs[2], locs[1], locs[0]},
148 Value: []int64{100},
149 },
150 {
151 Location: []*profile.Location{locs[1], locs[0]},
152 Value: []int64{200},
153 },
154 },
155 Location: locs,
156 Function: funcs,
157 Mapping: mapping,
158 }
159}
160
161type testFlags map[string]any
162

Callers 3

TestTopTableFunction · 0.70
TestFlameGraphFunction · 0.70
TestSourceFunction · 0.70

Calls

no outgoing calls

Tested by 3

TestTopTableFunction · 0.56
TestFlameGraphFunction · 0.56
TestSourceFunction · 0.56

Used in the wild real call sites across dependent graphs

searching dependent graphs…