title: Android NDK profiling tools
body: <p>Trying to profile my native libraries on Android, I have concerned that there is a lack of free profiling tools for this platform (specifically to profile native libraries).</p>
  
  <p>As said <a href="https://stackoverflow.com/questions/32357601/profile-shared-library-android-ndk-application">here</a> and <a href="https://www.virag.si/2015/08/profiling-native-ndk-code-in-android/" rel="noreferrer">here</a> two alternatives are available:</p>
  
  <ol>
  <li><a href="https://github.com/richq/android-ndk-profiler" rel="noreferrer">android-ndk-profiler</a>: Intrusive profiling.</li>
  <li><a href="https://github.com/google/fplutil" rel="noreferrer">fplutil</a>: Non-intrusive profiling.</li>
  </ol>
  
  <p>The first option interferes in the execution while the profiler is active, and as the <a href="https://github.com/richq/android-ndk-profiler/blob/master/README.mkd" rel="noreferrer">readme file of the android-ndk-profiler</a> sais: "<em>As an alternative please try out Google's own FPL Utils - NDK perf, which provides a non-intrusive way to profile your applications using Linux perf</em>".</p>
  
  <p>However, this new tool looks to only works on <a href="https://github.com/google/fplutil/blob/master/bin/android_ndk_perf.py#L58" rel="noreferrer">two specific devices</a>:</p>
  
  <pre><code>## Set of tested devices that are known to support perf.
  SUPPORTED_DEVICES = set([
      'mantaray',  # Nexus 10
      'nakasi',  # Nexus 7 (2012)
  ])
  </code></pre>
  
  <p>It looks like the device should have "Linux Perf" support to use fplutis profiler.</p>
  
  <p>Is there any other device apart of Nexus 10 and Nexus 7 (2012) where this profiling tool can be used?</p>
  
  <p>Is there a way to active this "Linux Perf" support on other devices? (changing the rom for example)</p>
  
  <p>Any other (newer) alternative?</p>
  
  <p>Thanks.</p>
  
  <p>NOTE: Some other answers like <a href="https://stackoverflow.com/questions/4446093/memory-debugging-tools-for-android-ndk-c-code">this</a> or <a href="https://stackoverflow.com/questions/16703135/profiling-android-ndk-plain-c-c-executable">this</a> suggest to use Valgrid, but I assume that it is an old alternative, and it is deprecated nowadays.</p>