diff options
author | Etan Cohen <etancohen@google.com> | 2017-06-28 10:31:36 -0700 |
---|---|---|
committer | Etan Cohen <etancohen@google.com> | 2017-06-30 17:00:28 -0700 |
commit | 34c8241b4b1d68cf98fad51cd0e56295e2721c6d (patch) | |
tree | eecff0a6799df858064e1735dfc2f4e48eca41d4 /service | |
parent | da389f4b673e0f3fe54dc5b1123221037eb96e42 (diff) |
[AWARE] Simplify Discovery Session metrics collection
Simplify metric collection - there's no need to keep an ongoing datbase
of information since that is already kept by the state machine. Simply
calculate updated max on every metric update.
Bug: 26565416
Test: unit tests passing
Change-Id: Ib0316663b37def153640eb2ed1c746c11423e755
Diffstat (limited to 'service')
-rw-r--r-- | service/java/com/android/server/wifi/aware/WifiAwareMetrics.java | 34 |
1 files changed, 13 insertions, 21 deletions
diff --git a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java index ba8a596e8..d99721647 100644 --- a/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java +++ b/service/java/com/android/server/wifi/aware/WifiAwareMetrics.java @@ -76,9 +76,9 @@ public class WifiAwareMetrics { private SparseIntArray mHistogramAttachDuration = new SparseIntArray(); // discovery data - private SparseIntArray mMaxPublishByUid = new SparseIntArray(); - private SparseIntArray mMaxSubscribeByUid = new SparseIntArray(); - private SparseIntArray mMaxDiscoveryByUid = new SparseIntArray(); + private int mMaxPublishInApp = 0; + private int mMaxSubscribeInApp = 0; + private int mMaxDiscoveryInApp = 0; private int mMaxPublishInSystem = 0; private int mMaxSubscribeInSystem = 0; private int mMaxDiscoveryInSystem = 0; @@ -238,10 +238,10 @@ public class WifiAwareMetrics { } synchronized (mLock) { - mMaxPublishByUid.put(uid, Math.max(mMaxPublishByUid.get(uid), numPublishesOnUid)); - mMaxSubscribeByUid.put(uid, Math.max(mMaxSubscribeByUid.get(uid), numSubscribesOnUid)); - mMaxDiscoveryByUid.put(uid, - Math.max(mMaxDiscoveryByUid.get(uid), numPublishesOnUid + numSubscribesOnUid)); + mMaxPublishInApp = Math.max(mMaxPublishInApp, numPublishesOnUid); + mMaxSubscribeInApp = Math.max(mMaxSubscribeInApp, numSubscribesOnUid); + mMaxDiscoveryInApp = Math.max(mMaxDiscoveryInApp, + numPublishesOnUid + numSubscribesOnUid); mMaxPublishInSystem = Math.max(mMaxPublishInSystem, numPublishesInSystem); mMaxSubscribeInSystem = Math.max(mMaxSubscribeInSystem, numSubscribesInSystem); mMaxDiscoveryInSystem = Math.max(mMaxDiscoveryInSystem, @@ -313,9 +313,9 @@ public class WifiAwareMetrics { log.histogramAttachDurationMs = histogramToProtoArray(mHistogramAttachDuration, DURATION_LOG_HISTOGRAM); - log.maxConcurrentPublishInApp = max(mMaxPublishByUid); - log.maxConcurrentSubscribeInApp = max(mMaxSubscribeByUid); - log.maxConcurrentDiscoverySessionsInApp = max(mMaxDiscoveryByUid); + log.maxConcurrentPublishInApp = mMaxPublishInApp; + log.maxConcurrentSubscribeInApp = mMaxSubscribeInApp; + log.maxConcurrentDiscoverySessionsInApp = mMaxDiscoveryInApp; log.maxConcurrentPublishInSystem = mMaxPublishInSystem; log.maxConcurrentSubscribeInSystem = mMaxSubscribeInSystem; log.maxConcurrentDiscoverySessionsInSystem = mMaxDiscoveryInSystem; @@ -355,9 +355,9 @@ public class WifiAwareMetrics { mAttachStatusData.clear(); mHistogramAttachDuration.clear(); - mMaxPublishByUid.clear(); - mMaxSubscribeByUid.clear(); - mMaxDiscoveryByUid.clear(); + mMaxPublishInApp = 0; + mMaxSubscribeInApp = 0; + mMaxDiscoveryInApp = 0; mMaxPublishInSystem = 0; mMaxSubscribeInSystem = 0; mMaxDiscoveryInSystem = 0; @@ -579,12 +579,4 @@ public class WifiAwareMetrics { return WifiMetricsProto.WifiAwareLog.UNKNOWN_HAL_STATUS; } } - - private int max(SparseIntArray array) { - int max = 0; - for (int i = 0; i < array.size(); ++i) { - max = Math.max(max, array.valueAt(i)); - } - return max; - } } |