수천 라인의 거대한 프레임 워크와 일부 MB를 내 프로젝트에 추가하지 않고도 간단한 계산으로 CPU 계산 능력을 벤치 마크하려고합니다.CPU 계산 능력 벤치마킹
이 샘플 코드는 개발했습니다. 그것은 100 배나되는 큰 일을합니다. 이 거대한 임무 (benchmark() 함수)는 수학 복합 계산을 수행하고 100ms의 기간 동안 카운터를 증가시키는 잠시 동안 이루어집니다. 100ms마다 benchmark() 함수가 복잡한 수학 계산을 완료 한 횟수를 로그에 인쇄합니다.
좋아, 그래서, 그 계산에 화면에 100 번 인쇄했습니다.
첫 번째 시간은 내가 얻을 벤치 마크 실행 올바른 결과, 더 많거나 벤치 마크의 100 반복 각각에 대해 동일한 로그 결과 미만 :
08-18 13:09:52.806 26543-27748/com.mytestapp D/XXXX: Iteration: 0 Result: 118200
08-18 13:09:52.906 26543-27748/com.mytestapp D/XXXX: Iteration: 1 Result: 171580
08-18 13:09:53.006 26543-27748/com.mytestapp D/XXXX: Iteration: 2 Result: 170654
08-18 13:09:53.106 26543-27748/com.mytestapp D/XXXX: Iteration: 3 Result: 168676
08-18 13:09:53.206 26543-27748/com.mytestapp D/XXXX: Iteration: 4 Result: 168372
08-18 13:09:53.306 26543-27748/com.mytestapp D/XXXX: Iteration: 5 Result: 165558
08-18 13:09:53.406 26543-27748/com.mytestapp D/XXXX: Iteration: 6 Result: 171368
08-18 13:09:53.506 26543-27748/com.mytestapp D/XXXX: Iteration: 7 Result: 171680
08-18 13:09:53.606 26543-27748/com.mytestapp D/XXXX: Iteration: 8 Result: 171516
08-18 13:09:53.706 26543-27748/com.mytestapp D/XXXX: Iteration: 9 Result: 171598
그러나 수가 감소하기 시작 일부 실행 후
, 나는 왜 그런지 이해하지 못한다 :08-18 13:10:20.850 26543-28161/com.mytestapp D/XXXX: Iteration: 1 Result: 94320
08-18 13:10:20.951 26543-28161/com.mytestapp D/XXXX: Iteration: 2 Result: 90364
08-18 13:10:21.051 26543-28161/com.mytestapp D/XXXX: Iteration: 3 Result: 94240
08-18 13:10:21.152 26543-28161/com.mytestapp D/XXXX: Iteration: 4 Result: 93676
08-18 13:10:21.252 26543-28161/com.mytestapp D/XXXX: Iteration: 5 Result: 91554
08-18 13:10:21.352 26543-28161/com.mytestapp D/XXXX: Iteration: 6 Result: 94358
08-18 13:10:21.452 26543-28161/com.mytestapp D/XXXX: Iteration: 7 Result: 90954
08-18 13:10:21.552 26543-28161/com.mytestapp D/XXXX: Iteration: 8 Result: 94874
08-18 13:10:21.652 26543-28161/com.mytestapp D/XXXX: Iteration: 9 Result: 94464
잠시 기다렸다가 다시 시도하면 결과가 정상 값으로 다시 증가한다.
왜이 동작입니까? 이를 피하고 올바른 벤치 마크 결과를 얻는 방법은 무엇입니까?
이 내 예제 코드입니다 :
public void benchmarkIterator(){
int result = 0;
int iterations = 100;
for (int i=0; i<iterations; i++){
result = benchmark();
Log.d("XXXX", "Iteration: "+i+" Result: "+result);
}
}
....
public int benchmark(){
long startTime = System.currentTimeMillis();
int count=0;
double aux=0;
while((System.currentTimeMillis()-startTime)<100){
count++;
double d = 7777777777d;
aux = 0;
aux=aux+(int)(aux+Math.sin(d)*Math.cos(d));
}
return count;
}
더 큰 결과는 더 빠른 CPU를 의미합니다. 그 100 MS에서 더 많은 수학 작전이 만들어 졌다는 뜻인가요? 그것은 어떤 최적화 또는 JIT 물건 일 수 있을까? – Yazan
결과가 높을수록 가장 빠른 수학 계산이이 CPU를 갖습니다 – NullPointerException
열이 과열되고 열이 빠져 나갈 수 있습니까? – X3Btel