我怎么能以编程方式强调手机的CPU?

Moh*_*dib 7 cpu android processor stress-testing root

所以我把我的手机超频到了1.664ghz,我知道有些应用可以测试你的手机的CPU性能和修饰器,但我想自己做一些.真正让CPU工作的最佳方法是什么?我只是想做一个for循环做一百万次迭代做一些耗时的数学......但这不起作用,因为我的手机在几毫秒内做到了我认为......我尝试了数万亿次迭代......应用程序冻结,但我的任务管理器甚至没有显示应用程序使用的CPU.通常压力测试应用程序显示为红色并说cpu:85%ram:10mb ...那么我怎样才能真正让我的处理器认真思考?

小智 2

要编译正则表达式字符串:

Pattern p1 = Pattern.compile("a*b"); // a simple regex
// slightly more complex regex: an attempt at validating email addresses
Pattern p2 = Pattern.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b");
Run Code Online (Sandbox Code Playgroud)

您需要在后台线程中启动它们:

class RegexThread extends Thread {
   RegexThread() {
      // Create a new, second thread
      super("Regex Thread");
      start(); // Start the thread
   } 

   // This is the entry point for the second thread.
   public void run() {
      while(true) {
        Pattern p = Pattern.compile("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b");
      }
   }
}

class CPUStresser {
   public static void main(String args[]) {
      static int NUM_THREADS = 10, RUNNING_TIME = 120; // run 10 threads for 120s
      for(int i = 0; i < NUM_THREADS; ++i) {
         new RegexThread(); // create a new thread
      }
      Thread.sleep(1000 * RUNNING_TIME);
   }
}
Run Code Online (Sandbox Code Playgroud)

(以上代码摘自此处

看看情况如何。