private float getBenchmark() { mDoingBenchmark = true; mTest.setupBenchmark(); long result = 0; long runtime = 1000; if (mToggleLong) { runtime = 10000; } if (mToggleDVFS) { mDvfsWar.go(); } // Log.v("rs", "Warming"); long t = java.lang.System.currentTimeMillis() + 250; do { mTest.runTest(); mTest.finish(); } while (t > java.lang.System.currentTimeMillis()); // mHandler.sendMessage(Message.obtain()); // Log.v("rs", "Benchmarking"); int ct = 0; t = java.lang.System.currentTimeMillis(); do { mTest.runTest(); mTest.finish(); ct++; } while ((t + runtime) > java.lang.System.currentTimeMillis()); t = java.lang.System.currentTimeMillis() - t; float ft = (float) t; ft /= ct; mTest.exitBenchmark(); mDoingBenchmark = false; android.util.Log.v("rs", "bench " + ft); return ft; }
// Run one loop of kernels for at least the specified minimum time. // The function returns the average time in ms for the test run private Result runBenchmarkLoop(float minTime) { Result r = new Result(); long t = java.lang.System.currentTimeMillis(); r.testInfo = mTest.getTestInfo(); do { // Run the kernel mTest.runTest(); r.iterations++; // Send our RS message handler a message so we know when this work has completed mRS.sendMessage(0, null); long t2 = java.lang.System.currentTimeMillis(); r.totalTime += (t2 - t) / 1000.f; t = t2; } while (r.totalTime < minTime); // Wait for any stray operations to complete and update the final time mRS.finish(); long t2 = java.lang.System.currentTimeMillis(); r.totalTime += (t2 - t) / 1000.f; t = t2; return r; }
void runTest() { mTest.runTest(); }