MCPcopy Create free account
hub / github.com/apache/thrift / profile_print_info

Function profile_print_info

lib/cpp/src/thrift/VirtualProfiling.cpp:297–339  ·  view source on GitHub ↗

* Print the recorded profiling information to the specified file. */

Source from the content-addressed store, hash-verified

295 * Print the recorded profiling information to the specified file.
296 */
297void profile_print_info(FILE* f) {
298 typedef std::vector<std::pair<Key, size_t> > BacktraceVector;
299
300 CountGreater is_greater;
301
302 // Grab both locks for the duration of the print operation,
303 // to ensure the output is a consistent snapshot of a single point in time
304 Guard generic_calls_guard(generic_calls_mutex);
305 Guard virtual_calls_guard(virtual_calls_mutex);
306
307 // print the info from generic_calls, sorted by frequency
308 //
309 // We print the generic_calls info ahead of virtual_calls, since it is more
310 // useful in some cases. All T_GENERIC_PROTOCOL calls can be eliminated
311 // from most programs. Not all T_VIRTUAL_CALLs will be eliminated by
312 // converting to templates.
313 BacktraceVector gp_sorted(generic_calls.begin(), generic_calls.end());
314 std::sort(gp_sorted.begin(), gp_sorted.end(), is_greater);
315
316 for (BacktraceVector::const_iterator it = gp_sorted.begin(); it != gp_sorted.end(); ++it) {
317 Key const& key = it->first;
318 size_t const count = it->second;
319 fprintf(f,
320 "T_GENERIC_PROTOCOL: %zu calls to %s with a %s:\n",
321 count,
322 key.getTypeName(),
323 key.getTypeName2());
324 key.getBacktrace()->print(f, 2);
325 fprintf(f, "\n");
326 }
327
328 // print the info from virtual_calls, sorted by frequency
329 BacktraceVector vc_sorted(virtual_calls.begin(), virtual_calls.end());
330 std::sort(vc_sorted.begin(), vc_sorted.end(), is_greater);
331
332 for (BacktraceVector::const_iterator it = vc_sorted.begin(); it != vc_sorted.end(); ++it) {
333 Key const& key = it->first;
334 size_t const count = it->second;
335 fprintf(f, "T_VIRTUAL_CALL: %zu calls on %s:\n", count, key.getTypeName());
336 key.getBacktrace()->print(f, 2);
337 fprintf(f, "\n");
338 }
339}
340
341/**
342 * Print the recorded profiling information to stdout.

Callers

nothing calls this directly

Calls 6

getTypeName2Method · 0.80
getBacktraceMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
getTypeNameMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected