Profile with gperftools

Table of Contents

SUMMARY

From the last two articles(profile with gprofprofile with oprofile), you may know some experiences of profile with C/C++ program. So let’s take a look at a new tool from google, called “gperftools“, full name is “Google performance tools”.

What are the differences?

We know gprof and oprofile, but why gperftools? Ok, take it easy, easy… Let me show you all:

First, we know gprof need to re-compile the program with “-pg”, it’s not a system profile tool, and it do multiple threads profile so hard and sometimes it’s not so precise. However, oprofile can solve them much easier, but it always shows all program results during the profile time, and we need the permission of sudo.

So, you can take the gperftools if you want to do profile with a multiple threads program without permission of sudo. I think it’s a much better choose than these two tools. Another reason why you choose it is that gperftools can generate a nice graph by itself. So, why not? :D just try it.

WORK FLOW

  • link with “-lprofiler” and re-compile your program
  • run “env CPUPROFILE=/tmp/result.prof ./myprogram”
  • pprof –pdf ./myprogram /tmp/result.prof > result_of_profile.pdf

For generating the graph, we require the “dot”, and the simple way to get dot, we can install the graphviz. And there are also many options to adjust the result of your profile, look up the document. Have fun :D

1 thought on “Profile with gperftools”

  1. Hi my name is Cameron and I just wanted to send you a quick message here instead of calling you. I came to your Profile with gperftools – Final Blog page and noticed you could have a lot more hits. I have found that the key to running a popular website is making sure the visitors you are getting are interested in your website topic. There is a company that you can get keyword targeted traffic from and they let you try the service for free for 7 days. I managed to get over 300 targeted visitors to day to my website. https://fsuh.de/yourls/C

Comments are closed.