Home > Uncategorized > Google Perftools

Google Perftools

As Oprofile has been removed from Debian, I needed to find alternative. perf was the most natural one but it currently does not support dwarf CFI stack unwinding. On amd64 Linux distro, it means that the application to be profiled and all libraries must be rebuilt with -fno-fomit-frame-pointer. A patch to enable CFI stack unwinding as been submitted but not accepted. Without it, it’s not possible to have a hierarchical and cumulative view. It make perf almost unusable for application profiling.

There I tried Google perftools. It doesn’t use hardware register like oprofile or perf but as explained in the documentation it is nice for sample based CPU profiling. An executable built with -g -O2 can be profiled without any modifications. The profiling output can even be browsed in kcachegrind.

Here are some python lines taken from there that I use to profile a C++ library providing a python binding:

#! /usr/bin/env python
import ctypes.util
google_profiler = ctypes.util.find_library('profiler')
libprofiler = ctypes.CDLL(google_profiler)
#your code to be profiled
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: