title: Android how to measure FPS of a View or Application programmatically
body: <p>I'd like to measure the FPS (refresh rate) of a certain Android View which uses TextureView. To do this, I need some way to measure FPS programmatically (e.g. not using ADB.exe and not using third party apps or tools). </p>
  
  <p>I have seen <a href="https://stackoverflow.com/questions/8907917/how-to-measure-fps-on-android-during-app-development">this question</a> but it does not answer where to log frame time.</p>
  
  <p>Is there an API within Android to get an event when the screen refreshes or is composed? Using this it would be relatively simple to measure frame time and hence calculate FPS. </p>
  
  <p>Same question for CPU usage. Any or all APIs to measure performance appreciated!</p>