如何以编程方式对手机的 CPU 施加压力?

发布于 2024-12-04 06:45:36 字数 373 浏览 2 评论 0原文

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

So i overclocked my phone to 1.664ghz and I know there are apps that test your phone's CPU performance and stressers but I would like to make my own someway. What is the best way to really make your CPU work? I was thinking just making a for loop do 1 million iterations of doing some time-consuming math...but that did not work becuase my phone did it in a few milliseconds i think...i tried trillions of iterations...the app froze but my task manager did not show the cpu even being used by the app. Usually stress test apps show up as red and say cpu:85% ram: 10mb ...So how can i really make my processor seriously think?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

眼泪都笑了 2024-12-11 06:45:36

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

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");

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

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);
   }
}

以上代码取自此处)

看看情况如何。

To compile a regex string:

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");

You need to launch these in background threads:

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);
   }
}

(above code appropriated from here)

See how that goes.

盛装女皇 2024-12-11 06:45:36

我建议进行稍微不同的测试,它不是简单的数学算法和函数。有很多看起来很奇怪的测试,其结果总是包含所有评论。您启动该应用程序,它会运行一段时间,然后为您提供标准分数的结果。点数越多(或更少),则认为该设备越好。但比较结果在现实生活中的意义并不总是明确的。但并非全部。
说到数学,首先想到的是大量的小数位数计算以及计算“pi”这个数字的任务

。没问题,我们会做的:

这是第一个测试 - “数字 Pi” - 你的手机需要多长时间才能计算出 Pi 的一千万位数字 (3.14)(如果有人说了这句话) 就会立即去精神病院。

一百年前,当你感觉手机速度慢时, 你转动/扭转接口。但如何衡量它 - 目前还不清楚。
愤怒的小鸟在不同的时间在不同的设备上运行 - 也许测试“愤怒的小鸟”

我们想得更远 - 进行更多测试,“厚书”和“大页面”。

计算算法:

  1. 测试“Pi”

取速度Pi。
使用慢速算法“亚伯拉罕·夏普系列”计算一千万分。重复测量几次,取平均值。

  1. 测试“愤怒的小鸟”

拿第一个愤怒的小鸟(不是必需的,但这些版本不是最优化的)

测量时间从启动到第一声音乐退出,重复几次并测试

  1. “大页面”

的平均值,您可以使用您最喜欢的浏览器来测量。

你可以使用此链接(对不起,西里尔字母)

此页面是通过使用“维护的”计算机浏览器”以及图片。总共有 6.5 Mb 和 99 个文件(我仍然在这个页面上保存了一个小声音文件的存储版本)

所有 99 个文件上传到手机。关闭 Wi-Fi 和移动互联网(这很重要!)

单击“后退”按钮,然后单击“前进”并测量页面完全加载的时间。如此几次。后退前进,后退前进。像往常一样,我们取平均值。

所有结果均以秒为单位给出。

在测试所有支持 microSD 卡的设备时,都是同一张卡 - Transcend 16 Gb,class 10。以及上面的所有数据。

好吧,一些设备的测试实际结果测试结果

I would suggest a slightly different test, it is not a simple mathematical algorithms and functions. There are plenty of odd-looking tests whose results always contains all reviews. You launch the application, it works for a while, and then gives you the result in standard scores. The more points more (or less), it is considered that the device better. But that the comparison results mean in real life, is not always clear. And not all.
Regard to mathematics, the first thing that comes to mind is a massive amount of counting decimal places and the task to count the number "pi"

OK. No problem, we will do it:

Here's a test number one - "The Number Pi" - how long it takes your phone to calculate the ten million digits of Pi (3.14) (if someone said this phrase a hundred years ago, exactly would be immediately went to a psychiatric hospital)

When you feel that the phone is slow. You turn / twist interface. But how to measure it - it is unclear.
Angry Birds run on different devices at different times - perhaps test "Angry Birds"

We think further - get a couple more tests, "heavy book" and "a large page."

algorithm of calculation:

  1. Test "of Pi"

Take the Speed Pi.
Count ten million marks by using a slow algorithm "Abraham Sharp Series. Repeat measurements several times, take the average.

  1. Test "Angry Birds"

Take the very first Angry Birds (not required, but these versions are not the most optimized)

Measure the time from launch to the first sounds of music. Exit. Immediately run over and over again. Repeat several times and take the average.

  1. Test "Large Page"

Measure the load time of heavy site pages. You can do it with your favorite browser :)

You can use This link (sorry for the Cyrillic)

This page is maintained by using "computers browser" along with pictures. Total turns out 6.5 Mb and 99 files (I'm still on this page in its stored version of a small sound file)

All 99 files upload to the phone. Turn off Wi-Fi and mobile Internet (this is important!)

Page opens with your browser. Click the "back" button. And now click "Forward" and measure the time the page is fully loaded. And so a few times. Back-forward, backward-forward. As usual, we take the average.

All results are given in seconds.

During testing all devices that support microSD cards, was one and the same card-Transcend 16 Gb, class 10. And all data on it.

Well, the actual results of the tests for some devices TEST RESULT

音栖息无 2024-12-11 06:45:36

https://play.google.com/store/apps/详细信息?id=xcom.saplin.xOPS - 该应用程序在多个线程(2 倍核心数)上处理数字(整数和浮点数)并构建性能和 CPU 温度图表。

屏幕截图

https://github.com/maxim-saplin/xOPS-Console/blob/master/Saplin.xOPS/Compute.cs - 这是应用程序的核心

https://play.google.com/store/apps/details?id=xcom.saplin.xOPS - the app crunches numbers (integer and float) on multiple threads (2x number of cores) and builds performance and CPU temperature graphs.

Screen shot

https://github.com/maxim-saplin/xOPS-Console/blob/master/Saplin.xOPS/Compute.cs - that's the core of the app

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文