tam*_*ner -3 java testing processing performance android
我想比较一个Android设备和一个Linux虚拟机的计算性能.(我的硕士论文的一部分)测试必须使用某种输入(例如图像,或只是数字),并且必须也有一些输出.
例如,jar文件可以制作一些图像的全景图.或者也许是密码破解者.
另一个要求是,必须以编程方式启动测试.所以必须有可能,通过java方法调用启动全景制作或密码破解.
是否有开源项目或jar文件来进行此测试?
更新:链接的答案不是我搜索的:@linski有想法,没有实现.如果任务可能是"现实生活"情景会更好.例如,获取全景图,或破解密码.
UPDATE2:"测试必须使用某种输入(例如图像,或只是数字),并且必须也有一些输出." +"如果任务可能是"现实生活"情景会更好"
这个Fibonnaci序列使我的所有4个核心达到接近100%:
public static BigInteger fib(BigInteger n) {
if (n.compareTo(BigInteger.ONE) == -1 || n.compareTo(BigInteger.ONE) == 0 ) return n;
else
return fib(n.subtract(BigInteger.ONE)).add(fib(n.subtract(BigInteger.ONE).subtract(BigInteger.ONE)));
}
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(10);
for (int j = 0; j < 10; j++) {
final int ID = j;
executorService.submit(new Runnable() {
public void run() {
for (int i=0;i < Integer.MAX_VALUE; i++) {
System.out.println(ID+" worker: "+i + ": " + fib(new BigInteger(String.valueOf(i))));
}
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
这很可能不足以进行基准测试:

但是写了15分钟,而且是CPU密集型的.关于现实生活中的例子,请阅读HotLicks评论.所以,如果你想在这里找到密码破解者是查找素数的最有效方法,这是打破RSA的基本操作:
public static boolean isPrime(BigInteger n) {
BigInteger counter = BigInteger.ONE.add(BigInteger.ONE);
boolean isPrime = true;
while (counter.compareTo(n) == -1) {
if (n.remainder(counter).compareTo(BigInteger.ZERO) == 0) {
isPrime = false;
break;
}
counter = counter.add(BigInteger.ONE);
}
return isPrime;
}
public static void main(String[] args) {
ExecutorService executorService = Executors.newFixedThreadPool(10);
for (int j = 0; j < 10; j++) {
final int ID = j;
executorService.submit(new Runnable() {
public void run() {
BigInteger number = BigInteger.ONE;
while(true) {
System.out.println(ID+" worker: "+number + ": " + isPrime(number));
number = number.add(BigInteger.ONE);
}
}
});
}
}
Run Code Online (Sandbox Code Playgroud)
它比Fibonnaci的CPU密集度更低:

可能是因为Fibonnaci有递归调用.
链接的答案是已知为CPU密集型的问题列表.它甚至提到了RSA挑战.