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

Method dump

src/flameGraph.cpp:114–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

112}
113
114void FlameGraph::dump(Writer& out, bool tree) {
115 _name_order = new u32[_cpool.size() + 1]();
116 _mintotal = _minwidth == 0 && tree ? _root._total / 1000 : (u64)(_root._total * _minwidth / 100);
117 int depth = _root.depth(_mintotal, _name_order);
118
119 if (tree) {
120 const char* tail = TREE_TEMPLATE;
121
122 tail = printTill(out, tail, "/*title:*/");
123 out << (_reverse ? "Backtrace" : "Call tree");
124
125 tail = printTill(out, tail, "/*type:*/");
126 out << (_counter == COUNTER_SAMPLES ? "samples" : "counter");
127
128 tail = printTill(out, tail, "/*count:*/");
129 out << Format().thousands(_root._total);
130
131 tail = printTill(out, tail, "/*tree:*/");
132
133 const char** names = new const char*[_cpool.size() + 1];
134 for (std::map<std::string, u32>::const_iterator it = _cpool.begin(); it != _cpool.end(); ++it) {
135 names[it->second] = it->first.c_str();
136 }
137 printTreeFrame(out, _root, 0, names);
138 delete[] names;
139
140 out << tail;
141 } else {
142 const char* tail = FLAMEGRAPH_TEMPLATE;
143
144 tail = printTill(out, tail, "/*height:*/300");
145 out << std::min(depth * 16, MAX_CANVAS_HEIGHT);
146
147 tail = printTill(out, tail, "/*title:*/");
148 out << _title;
149
150 tail = printTill(out, tail, "/*inverted:*/false");
151 // _inverted toggles the layout for reversed stacktraces from icicle to flamegraph
152 // and for default stacktraces from flamegraphs to icicle.
153 out << (_reverse ^ _inverted ? "true" : "false");
154
155 tail = printTill(out, tail, "/*depth:*/0");
156 out << depth;
157
158 tail = printTill(out, tail, "/*cpool:*/");
159 printCpool(out);
160
161 tail = printTill(out, tail, "/*frames:*/");
162 printFrame(out, FRAME_NATIVE << 28, _root, 0, 0);
163
164 tail = printTill(out, tail, "/*highlight:*/");
165
166 out << tail;
167 }
168
169 delete[] _name_order;
170}
171

Callers 3

buildFlameGraphMethod · 0.95
convertJfrToCollapsedMethod · 0.95

Calls 5

FormatClass · 0.85
thousandsMethod · 0.80
endMethod · 0.80
sizeMethod · 0.45
depthMethod · 0.45

Tested by 3

buildFlameGraphMethod · 0.76
convertJfrToCollapsedMethod · 0.76