From 07b79fbc8ba7c9f1ae81500369e4ff15457838a1 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Tue, 24 Sep 2024 13:49:01 -0700 Subject: [PATCH 1/2] OboeTester: add Intent to automate CPU LOad test Add options to enable ADPF and scrolling graphics Fixes #2103 --- .../oboetester/DynamicWorkloadActivity.java | 61 +++++++++++++++++++ .../com/mobileer/oboetester/MainActivity.java | 4 ++ .../oboetester/TestAudioActivity.java | 3 +- 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java index 8c94a3b7c..308264d0f 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java @@ -51,6 +51,11 @@ public class DynamicWorkloadActivity extends TestOutputActivityBase { // By default, set high workload to 70 voices, which is reasonable for most devices. public static final double WORKLOAD_PROGRESS_FOR_70_VOICES = 0.53; + public static final String KEY_USE_ADPF = "use_adpf"; + public static final boolean VALUE_DEFAULT_USE_ADPF = false; + public static final String KEY_SCROLL_GRAPHICS = "scroll_graphics"; + public static final boolean VALUE_DEFAULT_SCROLL_GRAPHICS = false; + private Button mStopButton; private Button mStartButton; private TextView mResultView; @@ -66,6 +71,7 @@ public class DynamicWorkloadActivity extends TestOutputActivityBase { private boolean mDrawChartAlways = true; private CheckBox mDrawAlwaysBox; private int mCpuCount; + private boolean mShouldUseADPF; private static final int WORKLOAD_LOW = 1; private int mWorkloadHigh; // this will get set later @@ -352,6 +358,10 @@ int getActivityType() { } public void startTest(View view) { + startTest(); + } + + private void startTest() { try { openAudio(); } catch (IOException e) { @@ -385,4 +395,55 @@ public void onStopTest() { updateButtons(false); super.onStopTest(); } + + + @Override + public void startTestUsingBundle() { + try { + StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration; + IntentBasedTestSupport.configureOutputStreamFromBundle(mBundleFromIntent, requestedOutConfig); + + // Specific options. + mShouldUseADPF = mBundleFromIntent.getBoolean(KEY_USE_ADPF, + VALUE_DEFAULT_USE_ADPF); + mDrawChartAlways = + mBundleFromIntent.getBoolean(KEY_SCROLL_GRAPHICS, + VALUE_DEFAULT_SCROLL_GRAPHICS); + + startTest(); + + runOnUiThread(() -> { + mPerfHintBox.setChecked(mShouldUseADPF); + setPerformanceHintEnabled(mShouldUseADPF); + mDrawAlwaysBox.setChecked(mDrawChartAlways); + }); + + int durationSeconds = IntentBasedTestSupport.getDurationSeconds(mBundleFromIntent); + if (durationSeconds > 0) { + // Schedule the end of the test. + Handler handler = new Handler(Looper.getMainLooper()); // UI thread + handler.postDelayed(new Runnable() { + @Override + public void run() { + stopAutomaticTest(); + } + }, durationSeconds * 1000); + } + } catch (Exception e) { + showErrorToast(e.getMessage()); + } finally { + mBundleFromIntent = null; + } + } + + void stopAutomaticTest() { + String report = getCommonTestReport(); + AudioStreamBase outputStream =mAudioOutTester.getCurrentAudioStream(); + report += "out.xruns = " + outputStream.getXRunCount() + "\n"; + report += "use.adpf = " + (mShouldUseADPF ? "yes" : "no") + "\n"; + report += "scroll.graphics = " + (mDrawChartAlways ? "yes" : "no") + "\n"; + onStopTest(); + maybeWriteTestResult(report); + mTestRunningByIntent = false; + } } diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/MainActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/MainActivity.java index f11a3bc69..5e3d19f8b 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/MainActivity.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/MainActivity.java @@ -46,6 +46,7 @@ public class MainActivity extends BaseOboeTesterActivity { public static final String VALUE_TEST_NAME_DATA_PATHS = "data_paths"; public static final String VALUE_TEST_NAME_OUTPUT = "output"; public static final String VALUE_TEST_NAME_INPUT = "input"; + public static final String VALUE_TEST_NAME_CPU_LOAD = "cpu_load"; static { // Must match name in CMakeLists.txt @@ -185,6 +186,9 @@ private Intent getTestIntent(Bundle bundle) { } else if (VALUE_TEST_NAME_OUTPUT.equals(testName)) { intent = new Intent(this, TestOutputActivity.class); intent.putExtras(bundle); + } else if (VALUE_TEST_NAME_CPU_LOAD.equals(testName)) { + intent = new Intent(this, DynamicWorkloadActivity.class); + intent.putExtras(bundle); } } return intent; diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java index 677bff0b7..97744d366 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestAudioActivity.java @@ -859,7 +859,8 @@ protected String getCommonTestReport() { int framesPerBurst = streamTester.getCurrentAudioStream().getFramesPerBurst(); status.framesPerCallback = getFramesPerCallback(); report.append("timestamp.latency = " + latencyStatistics.dump() + "\n"); - report.append(status.dump(framesPerBurst)); + // TODO The following report is not in a name=value format! + // report.append(status.dump(framesPerBurst)); } return report.toString(); From 0f3ba52acd1a1f074088f6ef770f23c1049652f5 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Fri, 4 Oct 2024 10:38:23 -0700 Subject: [PATCH 2/2] OboeTester: set ADPF variable in onClickListener --- .../com/mobileer/oboetester/DynamicWorkloadActivity.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java index 308264d0f..94929303c 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/DynamicWorkloadActivity.java @@ -299,8 +299,9 @@ public void onClick(View view) { mPerfHintBox.setOnClickListener(buttonView -> { CheckBox checkBox = (CheckBox) buttonView; - setPerformanceHintEnabled(checkBox.isChecked()); - mUseAltAdpfBox.setEnabled(!checkBox.isChecked()); + mShouldUseADPF = checkBox.isChecked(); + setPerformanceHintEnabled(mShouldUseADPF); + mUseAltAdpfBox.setEnabled(!mShouldUseADPF); }); CheckBox hearWorkloadBox = (CheckBox) findViewById(R.id.hear_workload);