MCPcopy Create free account
hub / github.com/async-profiler/async-profiler / printFrame

Method printFrame

src/flameGraph.cpp:172–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172void FlameGraph::printFrame(Writer& out, u32 key, const Trie& f, int level, u64 x) {
173 u32 name_and_type = _name_order[f.nameIndex(key)] << 3 | f.type(key);
174 bool has_extra_types = (f._inlined | f._c1_compiled | f._interpreted) &&
175 f._inlined < f._total && f._interpreted < f._total;
176
177 char* p = _buf;
178 if (level == _last_level + 1 && x == _last_x) {
179 p += snprintf(p, 100, "u(%u", name_and_type);
180 } else if (level == _last_level && x == _last_x + _last_total) {
181 p += snprintf(p, 100, "n(%u", name_and_type);
182 } else {
183 p += snprintf(p, 100, "f(%u,%d,%llu", name_and_type, level, x - _last_x);
184 }
185
186 if (f._total != _last_total || has_extra_types) {
187 p += snprintf(p, 100, ",%llu", f._total);
188 if (has_extra_types) {
189 p += snprintf(p, 100, ",%llu,%llu,%llu", f._inlined, f._c1_compiled, f._interpreted);
190 }
191 }
192
193 strcpy(p, ")\n");
194 out << _buf;
195
196 _last_level = level;
197 _last_x = x;
198 _last_total = f._total;
199
200 if (f._children.empty()) {
201 return;
202 }
203
204 std::vector<Node> children;
205 children.reserve(f._children.size());
206 for (auto it = f._children.begin(); it != f._children.end(); ++it) {
207 children.push_back(Node(it->first, _name_order[f.nameIndex(it->first)], it->second));
208 }
209 std::sort(children.begin(), children.end(), Node::orderByName);
210
211 x += f._self;
212 for (size_t i = 0; i < children.size(); i++) {
213 u32 key = children[i]._key;
214 const Trie* trie = children[i]._trie;
215 if (trie->_total >= _mintotal) {
216 printFrame(out, key, *trie, level + 1, x);
217 }
218 x += trie->_total;
219 }
220}
221
222void FlameGraph::printTreeFrame(Writer& out, const Trie& f, int level, const char** names) {
223 std::vector<Node> children;

Callers

nothing calls this directly

Calls 6

nameIndexMethod · 0.80
emptyMethod · 0.80
endMethod · 0.80
NodeClass · 0.70
typeMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected