summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmds/statsd/tools/loadtest/res/layout/activity_loadtest.xml43
-rw-r--r--cmds/statsd/tools/loadtest/res/values/strings.xml5
-rw-r--r--cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java44
-rw-r--r--cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java79
4 files changed, 153 insertions, 18 deletions
diff --git a/cmds/statsd/tools/loadtest/res/layout/activity_loadtest.xml b/cmds/statsd/tools/loadtest/res/layout/activity_loadtest.xml
index 2a254df2302a..f10b69dc3e69 100644
--- a/cmds/statsd/tools/loadtest/res/layout/activity_loadtest.xml
+++ b/cmds/statsd/tools/loadtest/res/layout/activity_loadtest.xml
@@ -137,13 +137,54 @@
android:text="@integer/duration_default"
android:textSize="30dp"/>
</LinearLayout>
- <CheckBox
+ <CheckBox
android:id="@+id/placebo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/placebo"
android:checked="false" />
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <CheckBox
+ android:id="@+id/include_count"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/count"
+ android:checked="true"/>
+ <CheckBox
+ android:id="@+id/include_duration"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/duration"
+ android:checked="true"/>
+ <CheckBox
+ android:id="@+id/include_event"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/event"
+ android:checked="true"/>
+ </LinearLayout>
+ <LinearLayout
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:orientation="horizontal">
+ <CheckBox
+ android:id="@+id/include_value"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/value"
+ android:checked="true"/>
+ <CheckBox
+ android:id="@+id/include_gauge"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/gauge"
+ android:checked="true"/>
+ </LinearLayout>
+
<Space
android:layout_width="1dp"
android:layout_height="30dp"/>
diff --git a/cmds/statsd/tools/loadtest/res/values/strings.xml b/cmds/statsd/tools/loadtest/res/values/strings.xml
index 522337ee656d..d0f77c65f660 100644
--- a/cmds/statsd/tools/loadtest/res/values/strings.xml
+++ b/cmds/statsd/tools/loadtest/res/values/strings.xml
@@ -26,5 +26,10 @@
<string name="duration_label">test duration (mins):&#160;</string>
<string name="start"> &#160;Start&#160; </string>
<string name="stop"> &#160;Stop&#160; </string>
+ <string name="count"> count </string>
+ <string name="duration"> duration </string>
+ <string name="event"> event </string>
+ <string name="value"> value </string>
+ <string name="gauge"> gauge </string>
</resources>
diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java
index 0d890fbb6e56..5fc4cf52f850 100644
--- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java
+++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/ConfigFactory.java
@@ -83,7 +83,9 @@ public class ConfigFactory {
* @param placebo If true, only return an empty config
* @return The serialized config
*/
- public byte[] getConfig(int replication, long bucketMillis, boolean placebo) {
+ public byte[] getConfig(int replication, long bucketMillis, boolean placebo, boolean includeCount,
+ boolean includeDuration, boolean includeEvent, boolean includeValue,
+ boolean includeGauge) {
StatsdConfig.Builder config = StatsdConfig.newBuilder()
.setName(CONFIG_NAME);
if (placebo) {
@@ -92,25 +94,35 @@ public class ConfigFactory {
int numMetrics = 0;
for (int i = 0; i < replication; i++) {
// metrics
- for (EventMetric metric : mTemplate.getEventMetricList()) {
- addEventMetric(metric, i, config);
- numMetrics++;
+ if (includeEvent) {
+ for (EventMetric metric : mTemplate.getEventMetricList()) {
+ addEventMetric(metric, i, config);
+ numMetrics++;
+ }
}
- for (CountMetric metric : mTemplate.getCountMetricList()) {
- addCountMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeCount) {
+ for (CountMetric metric : mTemplate.getCountMetricList()) {
+ addCountMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (DurationMetric metric : mTemplate.getDurationMetricList()) {
- addDurationMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeDuration) {
+ for (DurationMetric metric : mTemplate.getDurationMetricList()) {
+ addDurationMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (GaugeMetric metric : mTemplate.getGaugeMetricList()) {
- addGaugeMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeGauge) {
+ for (GaugeMetric metric : mTemplate.getGaugeMetricList()) {
+ addGaugeMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
- for (ValueMetric metric : mTemplate.getValueMetricList()) {
- addValueMetric(metric, i, bucketMillis, config);
- numMetrics++;
+ if (includeValue) {
+ for (ValueMetric metric : mTemplate.getValueMetricList()) {
+ addValueMetric(metric, i, bucketMillis, config);
+ numMetrics++;
+ }
}
// predicates
for (Predicate predicate : mTemplate.getPredicateList()) {
diff --git a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java
index 0a30ff8cf311..83f4b7bed558 100644
--- a/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java
+++ b/cmds/statsd/tools/loadtest/src/com/android/statsd/loadtest/LoadtestActivity.java
@@ -110,6 +110,11 @@ public class LoadtestActivity extends Activity {
private EditText mDurationText;
private TextView mReportText;
private CheckBox mPlaceboCheckBox;
+ private CheckBox mCountMetricCheckBox;
+ private CheckBox mDurationMetricCheckBox;
+ private CheckBox mEventMetricCheckBox;
+ private CheckBox mValueMetricCheckBox;
+ private CheckBox mGaugeMetricCheckBox;
/** When the load test started. */
private long mStartedTimeMillis;
@@ -129,6 +134,31 @@ public class LoadtestActivity extends Activity {
*/
private boolean mPlacebo;
+ /**
+ * Whether to include CountMetric in the config.
+ */
+ private boolean mIncludeCountMetric;
+
+ /**
+ * Whether to include DurationMetric in the config.
+ */
+ private boolean mIncludeDurationMetric;
+
+ /**
+ * Whether to include EventMetric in the config.
+ */
+ private boolean mIncludeEventMetric;
+
+ /**
+ * Whether to include ValueMetric in the config.
+ */
+ private boolean mIncludeValueMetric;
+
+ /**
+ * Whether to include GaugeMetric in the config.
+ */
+ private boolean mIncludeGaugeMetric;
+
/** The burst size. */
private int mBurst;
@@ -170,6 +200,7 @@ public class LoadtestActivity extends Activity {
initPeriod();
initDuration();
initPlacebo();
+ initMetricWhitelist();
// Hide the keyboard outside edit texts.
findViewById(R.id.outside).setOnTouchListener(new View.OnTouchListener() {
@@ -329,7 +360,9 @@ public class LoadtestActivity extends Activity {
getData();
// Create a config and push it to statsd.
- if (!setConfig(mFactory.getConfig(mReplication, mBucketMins * 60 * 1000, mPlacebo))) {
+ if (!setConfig(mFactory.getConfig(mReplication, mBucketMins * 60 * 1000, mPlacebo,
+ mIncludeCountMetric, mIncludeDurationMetric, mIncludeEventMetric,
+ mIncludeValueMetric, mIncludeGaugeMetric))) {
return;
}
@@ -548,4 +581,48 @@ public class LoadtestActivity extends Activity {
}
});
}
+
+ private void initMetricWhitelist() {
+ mCountMetricCheckBox = findViewById(R.id.include_count);
+ mCountMetricCheckBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mIncludeCountMetric = mCountMetricCheckBox.isChecked();
+ }
+ });
+ mDurationMetricCheckBox = findViewById(R.id.include_duration);
+ mDurationMetricCheckBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mIncludeDurationMetric = mDurationMetricCheckBox.isChecked();
+ }
+ });
+ mEventMetricCheckBox = findViewById(R.id.include_event);
+ mEventMetricCheckBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mIncludeEventMetric = mEventMetricCheckBox.isChecked();
+ }
+ });
+ mValueMetricCheckBox = findViewById(R.id.include_value);
+ mValueMetricCheckBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mIncludeValueMetric = mValueMetricCheckBox.isChecked();
+ }
+ });
+ mGaugeMetricCheckBox = findViewById(R.id.include_gauge);
+ mGaugeMetricCheckBox.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ mIncludeGaugeMetric = mGaugeMetricCheckBox.isChecked();
+ }
+ });
+
+ mIncludeCountMetric = mCountMetricCheckBox.isChecked();
+ mIncludeDurationMetric = mDurationMetricCheckBox.isChecked();
+ mIncludeEventMetric = mEventMetricCheckBox.isChecked();
+ mIncludeValueMetric = mValueMetricCheckBox.isChecked();
+ mIncludeGaugeMetric = mGaugeMetricCheckBox.isChecked();
+ }
}