Skip to content

Commit

Permalink
OboeTester: add Intent to automate CPU Load test (#2104)
Browse files Browse the repository at this point in the history
Add options to enable ADPF and scrolling graphics

Fixes #2103
  • Loading branch information
philburk authored Oct 5, 2024
1 parent 3dbbe19 commit c25613f
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -293,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);
Expand Down Expand Up @@ -352,6 +359,10 @@ int getActivityType() {
}

public void startTest(View view) {
startTest();
}

private void startTest() {
try {
openAudio();
} catch (IOException e) {
Expand Down Expand Up @@ -385,4 +396,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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,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();
Expand Down

0 comments on commit c25613f

Please sign in to comment.