1. Are you ready for the Galaxy S20? Here is everything we know so far!

Is it possible to programmatically measure methods CPU time? (not execution time)

Discussion in 'Android Development' started by kamieniarzk, Jul 20, 2021.

  1. kamieniarzk

    kamieniarzk Lurker
    Thread Starter

    I have an application that uses OpenCV to process images from the camera in real-time. The processing consists of several steps, wrapped in separate methods like filtering, thresholding, etc. I would like to have an estimate of CPU time used by each of the methods to make an estimate of their energy consumption. I know that I could do something like

    Code (Java):
    1. public long filter(Mat input) {
    2.    long time = System.elapsedRealtime();
    3.  
    4.    ...
    5.  
    6.    return System.elapsedRealtime() - time;
    7. }

    to get the execution time of each method call but I think since I'd like to correlate it with energy consumption it would not be precise enough. Is there some way to maybe get the total CPU time of the current process? (I know in Android Studio's Energy Profiler I could trace CPU time of methods but I wanted to know if this is achievable at runtime programmatically)
     



    1. Download the Forums for Android™ app!


      Download

       
Loading...
Similar Threads - possible programmatically measure
  1. mysorian
    Replies:
    0
    Views:
    229
  2. DGS6
    Replies:
    5
    Views:
    324
  3. Lane Lester
    Replies:
    0
    Views:
    220
  4. Lane Lester
    Replies:
    5
    Views:
    288
  5. Lane Lester
    Replies:
    7
    Views:
    346
  6. Jimmy the rebus dobs
    Replies:
    6
    Views:
    463
  7. Wendell Gutmann
    Replies:
    4
    Views:
    602
  8. Sanjit Keksar
    Replies:
    4
    Views:
    795
  9. Gary Olson
    Replies:
    8
    Views:
    882
  10. Rgarner
    Replies:
    6
    Views:
    801

Share This Page

Loading...