From 1ea51bf519bdfc0e04daa88b8788f06105c5599b Mon Sep 17 00:00:00 2001 From: Jeff Brown Date: Wed, 30 May 2012 19:17:47 -0700 Subject: [PATCH] Remove unused statistics code. Bug: 6559630 Change-Id: Iacdf4bb4c1c125c09305cbd8cb443c7c80cfc010 --- include/utils/Looper.h | 21 ------------- libs/utils/Looper.cpp | 68 ------------------------------------------ 2 files changed, 89 deletions(-) diff --git a/include/utils/Looper.h b/include/utils/Looper.h index 3c2905d59..96b971e97 100644 --- a/include/utils/Looper.h +++ b/include/utils/Looper.h @@ -27,9 +27,6 @@ // When defined, uses epoll_wait() for polling, otherwise uses poll(). #define LOOPER_USES_EPOLL -// When defined, logs performance statistics for tuning and debugging purposes. -//#define LOOPER_STATISTICS - #ifdef LOOPER_USES_EPOLL #include #else @@ -340,24 +337,6 @@ private: void wakeAndLock(); #endif -#ifdef LOOPER_STATISTICS - static const int SAMPLED_WAKE_CYCLES_TO_AGGREGATE = 100; - static const int SAMPLED_POLLS_TO_AGGREGATE = 1000; - - nsecs_t mPendingWakeTime; - int mPendingWakeCount; - - int mSampledWakeCycles; - int mSampledWakeCountSum; - nsecs_t mSampledWakeLatencySum; - - int mSampledPolls; - int mSampledZeroPollCount; - int mSampledZeroPollLatencySum; - int mSampledTimeoutPollCount; - int mSampledTimeoutPollLatencySum; -#endif - // This state is only used privately by pollOnce and does not require a lock since // it runs on a single thread. Vector mResponses; diff --git a/libs/utils/Looper.cpp b/libs/utils/Looper.cpp index d1aa664bc..95db28db0 100644 --- a/libs/utils/Looper.cpp +++ b/libs/utils/Looper.cpp @@ -98,20 +98,6 @@ Looper::Looper(bool allowNonCallbacks) : mPolling = false; mWaiters = 0; #endif - -#ifdef LOOPER_STATISTICS - mPendingWakeTime = -1; - mPendingWakeCount = 0; - mSampledWakeCycles = 0; - mSampledWakeCountSum = 0; - mSampledWakeLatencySum = 0; - - mSampledPolls = 0; - mSampledZeroPollCount = 0; - mSampledZeroPollLatencySum = 0; - mSampledTimeoutPollCount = 0; - mSampledTimeoutPollLatencySum = 0; -#endif } Looper::~Looper() { @@ -234,10 +220,6 @@ int Looper::pollInner(int timeoutMillis) { mResponses.clear(); mResponseIndex = 0; -#ifdef LOOPER_STATISTICS - nsecs_t pollStartTime = systemTime(SYSTEM_TIME_MONOTONIC); -#endif - #ifdef LOOPER_USES_EPOLL struct epoll_event eventItems[EPOLL_MAX_EVENTS]; int eventCount = epoll_wait(mEpollFd, eventItems, EPOLL_MAX_EVENTS, timeoutMillis); @@ -341,29 +323,6 @@ Done: } #endif -#ifdef LOOPER_STATISTICS - nsecs_t pollEndTime = systemTime(SYSTEM_TIME_MONOTONIC); - mSampledPolls += 1; - if (timeoutMillis == 0) { - mSampledZeroPollCount += 1; - mSampledZeroPollLatencySum += pollEndTime - pollStartTime; - } else if (timeoutMillis > 0 && result == ALOOPER_POLL_TIMEOUT) { - mSampledTimeoutPollCount += 1; - mSampledTimeoutPollLatencySum += pollEndTime - pollStartTime - - milliseconds_to_nanoseconds(timeoutMillis); - } - if (mSampledPolls == SAMPLED_POLLS_TO_AGGREGATE) { - ALOGD("%p ~ poll latency statistics: %0.3fms zero timeout, %0.3fms non-zero timeout", this, - 0.000001f * float(mSampledZeroPollLatencySum) / mSampledZeroPollCount, - 0.000001f * float(mSampledTimeoutPollLatencySum) / mSampledTimeoutPollCount); - mSampledPolls = 0; - mSampledZeroPollCount = 0; - mSampledZeroPollLatencySum = 0; - mSampledTimeoutPollCount = 0; - mSampledTimeoutPollLatencySum = 0; - } -#endif - // Invoke pending message callbacks. mNextMessageUptime = LLONG_MAX; while (mMessageEnvelopes.size() != 0) { @@ -454,13 +413,6 @@ void Looper::wake() { ALOGD("%p ~ wake", this); #endif -#ifdef LOOPER_STATISTICS - // FIXME: Possible race with awoken() but this code is for testing only and is rarely enabled. - if (mPendingWakeCount++ == 0) { - mPendingWakeTime = systemTime(SYSTEM_TIME_MONOTONIC); - } -#endif - ssize_t nWrite; do { nWrite = write(mWakeWritePipeFd, "W", 1); @@ -478,26 +430,6 @@ void Looper::awoken() { ALOGD("%p ~ awoken", this); #endif -#ifdef LOOPER_STATISTICS - if (mPendingWakeCount == 0) { - ALOGD("%p ~ awoken: spurious!", this); - } else { - mSampledWakeCycles += 1; - mSampledWakeCountSum += mPendingWakeCount; - mSampledWakeLatencySum += systemTime(SYSTEM_TIME_MONOTONIC) - mPendingWakeTime; - mPendingWakeCount = 0; - mPendingWakeTime = -1; - if (mSampledWakeCycles == SAMPLED_WAKE_CYCLES_TO_AGGREGATE) { - ALOGD("%p ~ wake statistics: %0.3fms wake latency, %0.3f wakes per cycle", this, - 0.000001f * float(mSampledWakeLatencySum) / mSampledWakeCycles, - float(mSampledWakeCountSum) / mSampledWakeCycles); - mSampledWakeCycles = 0; - mSampledWakeCountSum = 0; - mSampledWakeLatencySum = 0; - } - } -#endif - char buffer[16]; ssize_t nRead; do {