title: How to interpret the report of perf
body: <p>I'm learning how to use the tool <code>perf</code> to profile my c++ project. Here is my code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;thread&gt;
  #include &lt;mutex&gt;
  #include &lt;vector&gt;
  
  
  std::mutex mtx;
  long long_val = 0;
  
  void do_something(long &amp;val)
  {
      std::unique_lock&lt;std::mutex&gt; lck(mtx);
      for(int j=0; j&lt;1000; ++j)
          val++;
  }
  
  
  void thread_func()
  {
      for(int i=0; i&lt;1000000L; ++i)
      {
          do_something(long_val);
      }
  }
  
  
  int main(int argc, char* argv[])
  {
      std::vector&lt;std::unique_ptr&lt;std::thread&gt;&gt; threads;
      for(int i=0; i&lt;100; ++i)
      {
          threads.push_back(std::move(std::unique_ptr&lt;std::thread&gt;(new std::thread(thread_func))));
      }
      for(int i=0; i&lt;100; ++i)
      {
          threads[i]-&gt;join();
      }
      threads.clear();
      std::cout &lt;&lt; long_val &lt;&lt; std::endl;
      return 0;
  }
  </code></pre>
  
  <p>To compile it, I run <code>g++ -std=c++11 main.cpp -lpthread -g</code> and then I get the executable file named <code>a.out</code>.</p>
  
  <p>Then I run <code>perf record --call-graph dwarf -- ./a.out</code> and wait for 10 seconds, then I press <code>Ctrl+c</code> to interrupt the <code>./a.out</code> because it needs too much time to execute.</p>
  
  <p>Lastly, I run <code>perf report -g graph --no-children</code> and here is the output:</p>
  
  <p><a href="https://i.stack.imgur.com/xRN3g.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xRN3g.jpg" alt="enter image description here"></a></p>
  
  <p>My goal is to find which part of the code is the heaviest. So it seems that this output could tell me <code>do_something</code> is the heaviest part(46.25%). But when I enter into <code>do_something</code>, I can not understand what it is: <code>std::_Bind_simple</code>, <code>std::thread::_Impl</code> etc.</p>
  
  <p>So how to get more useful information from the output of <code>perf report</code>? Or we can't get more except the fact that <code>do_something</code> is the heaviest?</p>