Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OboeTester: add Intent to automate CPU Load test #2104

Merged
merged 2 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
philburk marked this conversation as resolved.
Show resolved Hide resolved

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);
robertwu1 marked this conversation as resolved.
Show resolved Hide resolved
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 @@ -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();
Expand Down