get rid of TimerProbe which is never used
This commit is contained in:
parent
d12529a149
commit
861db31eb9
3 changed files with 0 additions and 204 deletions
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_TIMER_PROBE_H
|
||||
#define ANDROID_TIMER_PROBE_H
|
||||
|
||||
#if 0 && defined(HAVE_POSIX_CLOCKS)
|
||||
#define ENABLE_TIMER_PROBE 1
|
||||
#else
|
||||
#define ENABLE_TIMER_PROBE 0
|
||||
#endif
|
||||
|
||||
#if ENABLE_TIMER_PROBE
|
||||
|
||||
#include <time.h>
|
||||
#include <sys/time.h>
|
||||
#include <utils/Vector.h>
|
||||
|
||||
#define TIMER_PROBE(tag) \
|
||||
static int _timer_slot_; \
|
||||
android::TimerProbe probe(tag, &_timer_slot_)
|
||||
#define TIMER_PROBE_END() probe.end()
|
||||
#else
|
||||
#define TIMER_PROBE(tag)
|
||||
#define TIMER_PROBE_END()
|
||||
#endif
|
||||
|
||||
#if ENABLE_TIMER_PROBE
|
||||
namespace android {
|
||||
|
||||
class TimerProbe {
|
||||
public:
|
||||
TimerProbe(const char tag[], int* slot);
|
||||
void end();
|
||||
~TimerProbe();
|
||||
private:
|
||||
struct Bucket {
|
||||
int mStart, mReal, mProcess, mThread, mCount;
|
||||
const char* mTag;
|
||||
int* mSlotPtr;
|
||||
int mIndent;
|
||||
};
|
||||
static Vector<Bucket> gBuckets;
|
||||
static TimerProbe* gExecuteChain;
|
||||
static int gIndent;
|
||||
static timespec gRealBase;
|
||||
TimerProbe* mNext;
|
||||
static uint32_t ElapsedTime(const timespec& start, const timespec& end);
|
||||
void print(const timespec& r, const timespec& p, const timespec& t) const;
|
||||
timespec mRealStart, mPStart, mTStart;
|
||||
const char* mTag;
|
||||
int mIndent;
|
||||
int mBucket;
|
||||
};
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -35,7 +35,6 @@ commonSources:= \
|
|||
SystemClock.cpp \
|
||||
TextOutput.cpp \
|
||||
Threads.cpp \
|
||||
TimerProbe.cpp \
|
||||
Timers.cpp \
|
||||
VectorImpl.cpp \
|
||||
ZipFileCRO.cpp \
|
||||
|
|
|
|||
|
|
@ -1,131 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <utils/TimerProbe.h>
|
||||
|
||||
#if ENABLE_TIMER_PROBE
|
||||
|
||||
#ifdef LOG_TAG
|
||||
#undef LOG_TAG
|
||||
#endif
|
||||
#define LOG_TAG "time"
|
||||
|
||||
namespace android {
|
||||
|
||||
Vector<TimerProbe::Bucket> TimerProbe::gBuckets;
|
||||
TimerProbe* TimerProbe::gExecuteChain;
|
||||
int TimerProbe::gIndent;
|
||||
timespec TimerProbe::gRealBase;
|
||||
|
||||
TimerProbe::TimerProbe(const char tag[], int* slot) : mTag(tag)
|
||||
{
|
||||
mNext = gExecuteChain;
|
||||
gExecuteChain = this;
|
||||
mIndent = gIndent;
|
||||
gIndent += 1;
|
||||
if (mIndent > 0) {
|
||||
if (*slot == 0) {
|
||||
int count = gBuckets.add();
|
||||
*slot = count;
|
||||
Bucket& bucket = gBuckets.editItemAt(count);
|
||||
memset(&bucket, 0, sizeof(Bucket));
|
||||
bucket.mTag = tag;
|
||||
bucket.mSlotPtr = slot;
|
||||
bucket.mIndent = mIndent;
|
||||
}
|
||||
mBucket = *slot;
|
||||
}
|
||||
clock_gettime(CLOCK_REALTIME, &mRealStart);
|
||||
if (gRealBase.tv_sec == 0)
|
||||
gRealBase = mRealStart;
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &mPStart);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &mTStart);
|
||||
}
|
||||
|
||||
void TimerProbe::end()
|
||||
{
|
||||
timespec realEnd, pEnd, tEnd;
|
||||
clock_gettime(CLOCK_REALTIME, &realEnd);
|
||||
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &pEnd);
|
||||
clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tEnd);
|
||||
print(realEnd, pEnd, tEnd);
|
||||
mTag = NULL;
|
||||
}
|
||||
|
||||
TimerProbe::~TimerProbe()
|
||||
{
|
||||
if (mTag != NULL)
|
||||
end();
|
||||
gExecuteChain = mNext;
|
||||
gIndent--;
|
||||
}
|
||||
|
||||
|
||||
uint32_t TimerProbe::ElapsedTime(const timespec& start, const timespec& end)
|
||||
{
|
||||
int sec = end.tv_sec - start.tv_sec;
|
||||
int nsec = end.tv_nsec - start.tv_nsec;
|
||||
if (nsec < 0) {
|
||||
sec--;
|
||||
nsec += 1000000000;
|
||||
}
|
||||
return sec * 1000000 + nsec / 1000;
|
||||
}
|
||||
|
||||
void TimerProbe::print(const timespec& r, const timespec& p,
|
||||
const timespec& t) const
|
||||
{
|
||||
uint32_t es = ElapsedTime(gRealBase, mRealStart);
|
||||
uint32_t er = ElapsedTime(mRealStart, r);
|
||||
uint32_t ep = ElapsedTime(mPStart, p);
|
||||
uint32_t et = ElapsedTime(mTStart, t);
|
||||
if (mIndent > 0) {
|
||||
Bucket& bucket = gBuckets.editItemAt(mBucket);
|
||||
if (bucket.mStart == 0)
|
||||
bucket.mStart = es;
|
||||
bucket.mReal += er;
|
||||
bucket.mProcess += ep;
|
||||
bucket.mThread += et;
|
||||
bucket.mCount++;
|
||||
return;
|
||||
}
|
||||
int index = 0;
|
||||
int buckets = gBuckets.size();
|
||||
int count = 1;
|
||||
const char* tag = mTag;
|
||||
int indent = mIndent;
|
||||
do {
|
||||
LOGD("%-30.30s: (%3d) %-5.*s time=%-10.3f real=%7dus process=%7dus (%3d%%) thread=%7dus (%3d%%)\n",
|
||||
tag, count, indent > 5 ? 5 : indent, "+++++", es / 1000000.0,
|
||||
er, ep, ep * 100 / er, et, et * 100 / er);
|
||||
if (index >= buckets)
|
||||
break;
|
||||
Bucket& bucket = gBuckets.editItemAt(index);
|
||||
count = bucket.mCount;
|
||||
es = bucket.mStart;
|
||||
er = bucket.mReal;
|
||||
ep = bucket.mProcess;
|
||||
et = bucket.mThread;
|
||||
tag = bucket.mTag;
|
||||
indent = bucket.mIndent;
|
||||
*bucket.mSlotPtr = 0;
|
||||
} while (++index); // always true
|
||||
gBuckets.clear();
|
||||
}
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Reference in a new issue