public void run() { while (mRun) { // Our loop for launching tests or benchmarks synchronized (this) { // We may have been asked to exit while waiting if (!mRun) return; } if (mBenchmarkMode) { // Loop over the tests we want to benchmark for (int ct = 0; (ct < mTestList.length) && mRun; ct++) { // For reproducibility we wait a short time for any sporadic work // created by the user touching the screen to launch the test to pass. // Also allows for things to settle after the test changes. mRS.finish(); try { sleep(250); } catch (InterruptedException e) { } // If we just ran a test, we destroy it here to relieve some memory pressure if (mTest != null) { mTest.destroy(); } // Select the next test mTest = changeTest(mTestList[ct], false); // If the user selected the "long pause" option, wait if (mTogglePause) { for (int i = 0; (i < 100) && mRun; i++) { try { sleep(100); } catch (InterruptedException e) { } } } // Run the test Result r = getBenchmark(); mTestResults[ct] = r.totalTime / r.iterations * 1000.f; mTestInfo[ct] = r.testInfo; } onBenchmarkFinish(mRun); } else { // Run the kernel runTest(); // Send our RS message handler a message so we know when this work has completed mRS.sendMessage(0, null); } } }
public void run() { Surface lastSurface = null; while (mRun) { synchronized (this) { try { this.wait(); } catch (InterruptedException e) { } if (!mRun) return; if ((mOutSurface == null) || (mOutPixelsAllocation == null)) { continue; } if (lastSurface != mOutSurface) { mOutDisplayAllocation.setSurface(mOutSurface); lastSurface = mOutSurface; } } if (mBenchmarkMode) { for (int ct = 0; (ct < mTestList.length) && mRun; ct++) { mRS.finish(); try { sleep(250); } catch (InterruptedException e) { } if (mTest != null) { mTest.destroy(); } mTest = changeTest(mTestList[ct]); if (mTogglePause) { for (int i = 0; (i < 100) && mRun; i++) { try { sleep(100); } catch (InterruptedException e) { } } } mTestResults[ct] = getBenchmark(); mHandler.sendMessage(Message.obtain()); } onBenchmarkFinish(mRun); } } }
public void exit() { mRun = false; synchronized (this) { notifyAll(); } try { this.join(); } catch (InterruptedException e) { } if (mTest != null) { mTest.destroy(); mTest = null; } mRS.destroy(); mRS = null; }