summaryrefslogtreecommitdiff
path: root/apct-tests/perftests/utils
diff options
context:
space:
mode:
authorSudheer Shanka <sudheersai@google.com>2016-08-17 19:34:58 -0700
committerSudheer Shanka <sudheersai@google.com>2016-08-19 16:36:23 -0700
commit53c23fdd5cf454c0f035e307ed5fda673b8b62dd (patch)
tree3fa3fc34b69a748414782cec8a3515e7cd2c3840 /apct-tests/perftests/utils
parent412b630bb677e5734287ee4439253e111aa7bad0 (diff)
Add usermanager related perf tests - part1
Bug: 30948225 Change-Id: I0668a012435e9954729e5085fdb4b1f5ce422d97
Diffstat (limited to 'apct-tests/perftests/utils')
-rw-r--r--apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
index 4213e4a3aa2b..b27d71b943a1 100644
--- a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
+++ b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java
@@ -48,7 +48,6 @@ public class BenchmarkState {
private static final int RUNNING = 2; // The benchmark is running.
private static final int RUNNING_PAUSED = 3; // The benchmark is temporary paused.
private static final int FINISHED = 4; // The benchmark has stopped.
- private static final int MIN_REPEAT_TIMES = 16;
private int mState = NOT_STARTED; // Current benchmark state.
@@ -64,10 +63,20 @@ public class BenchmarkState {
private double mMean = 0.0;
private double mStandardDeviation = 0.0;
+ // Number of iterations needed for calculating the stats.
+ private int mMinRepeatTimes = 16;
+
// Individual duration in nano seconds.
private ArrayList<Long> mResults = new ArrayList<>();
/**
+ * Sets the number of iterations needed for calculating the stats. Default is 16.
+ */
+ public void setMinRepeatTimes(int minRepeatTimes) {
+ mMinRepeatTimes = minRepeatTimes;
+ }
+
+ /**
* Calculates statistics.
*/
private void calculateSatistics() {
@@ -133,7 +142,7 @@ public class BenchmarkState {
mNanoPausedDuration = 0;
// To calculate statistics, needs two or more samples.
- if (mResults.size() > MIN_REPEAT_TIMES && currentTime > mNanoFinishTime) {
+ if (mResults.size() > mMinRepeatTimes && currentTime > mNanoFinishTime) {
calculateSatistics();
mState = FINISHED;
return false;
@@ -181,7 +190,7 @@ public class BenchmarkState {
sb.append("sigma=").append(standardDeviation()).append(", ");
sb.append("iteration=").append(mResults.size()).append(", ");
// print out the first few iterations' number for double checking.
- int sampleNumber = Math.min(mResults.size(), MIN_REPEAT_TIMES);
+ int sampleNumber = Math.min(mResults.size(), mMinRepeatTimes);
for (int i = 0; i < sampleNumber; i++) {
sb.append("No ").append(i).append(" result is ").append(mResults.get(i)).append(", ");
}