-2

I have the source for a benchmark test for Android, and I would like to modify it a bit.

As of right now, the benchmark test presumably runs the CPU at full load (100%), what I want to do is pause the benchmark test (or something similar in nature) to let the CPU cool down to a lower load percentage (maybe 10% or 20%) and then run the CPU at 100% again, doing this over and over.

How does one approach this problem?

Jason John
  • 934
  • 2
  • 12
  • 23
  • It depends on the sources. – eleven Jul 09 '14 at 13:22
  • Is there no general use case? I'm calling `Thread.sleep()` to pause the benchmark (for 3 minutes) but the stock CPU measurements (Show CPU usage from Developer Tools in Android) don't seem to be going down at all. – Jason John Jul 09 '14 at 13:37
  • So yes, in general you need to stop thread which loads CPU. But you need to know which exactly thread(or threads) do this work. – eleven Jul 09 '14 at 13:45

2 Answers2

0

I use the following on a program with no separate threads created

    try 
     {
        // thread to sleep for 1000 milliseconds
        Thread.sleep(1000);
     }
     catch (Exception e) 
     {
          System.out.println(e);
     }
Roy Longbottom
  • 1,192
  • 1
  • 6
  • 8
0

My issue of not being able to "cycle" the CPU was unrelated to Thread.sleep(), which @Fox suggested, but in regards to calling System.exit(0) in my activity instead of calling finish(). I don't know why, but it works as expected.

Anyone wanna explain why the CPU dials down after calling System.exit(0)? Maybe threads still running?

Jason John
  • 934
  • 2
  • 12
  • 23