diff options
| author | Android (Google) Code Review <android-gerrit@google.com> | 2009-11-23 06:58:11 -0800 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-11-23 06:58:11 -0800 |
| commit | d9f6271d56fca364fbf3c8eb190e8ccc6a040f75 (patch) | |
| tree | db53df07de4f8003cfedab3d3a4427a8e3cfb2f4 /WebKit/android | |
| parent | f49be335d71adf2b6d0e2dfa55d13b56376a62a8 (diff) | |
| parent | 716ed672a4274d2a4e960593e02a2cc59a96a82f (diff) | |
| download | external_webkit-d9f6271d56fca364fbf3c8eb190e8ccc6a040f75.zip external_webkit-d9f6271d56fca364fbf3c8eb190e8ccc6a040f75.tar.gz external_webkit-d9f6271d56fca364fbf3c8eb190e8ccc6a040f75.tar.bz2 | |
Merge change Ia4f91efd into eclair-mr2
* changes:
Moves get_thread_msec from JavaScriptCore/wtf/CurrentTime to WebKit/android/Timecounter.
Diffstat (limited to 'WebKit/android')
| -rw-r--r-- | WebKit/android/TimeCounter.cpp | 32 | ||||
| -rw-r--r-- | WebKit/android/TimeCounter.h | 13 | ||||
| -rw-r--r-- | WebKit/android/jni/PictureSet.cpp | 6 |
3 files changed, 34 insertions, 17 deletions
diff --git a/WebKit/android/TimeCounter.cpp b/WebKit/android/TimeCounter.cpp index 2bb7805..61584a7 100644 --- a/WebKit/android/TimeCounter.cpp +++ b/WebKit/android/TimeCounter.cpp @@ -34,6 +34,8 @@ #include "Node.h" #include "SystemTime.h" #include "StyleBase.h" +#include <utils/Log.h> +#include <wtf/CurrentTime.h> #if USE(JSC) #include "JSDOMWindow.h" @@ -41,14 +43,28 @@ #include <runtime/JSLock.h> #endif -#include <utils/Log.h> - using namespace WebCore; using namespace WTF; using namespace JSC; namespace android { +uint32_t getThreadMsec() +{ +#if defined(HAVE_POSIX_CLOCKS) + struct timespec tm; + + clock_gettime(CLOCK_THREAD_CPUTIME_ID, &tm); + return tm.tv_sec * 1000LL + tm.tv_nsec / 1000000; +#else + struct timeval now; + struct timezone zone; + + gettimeofday(&now, &zone); + return now.tv_sec * 1000LL + now.tv_usec / 1000; +#endif +} + #ifdef ANDROID_INSTRUMENT static double sStartTotalTime; @@ -94,7 +110,7 @@ void TimeCounter::record(enum Type type, const char* functionName) void TimeCounter::recordNoCounter(enum Type type, const char* functionName) { - uint32_t time = sEndWebCoreThreadTime = get_thread_msec(); + uint32_t time = sEndWebCoreThreadTime = getThreadMsec(); uint32_t elapsed = time - sStartTime[type]; sTotalTimeUsed[type] += elapsed; if (elapsed > 1000) @@ -105,7 +121,7 @@ void TimeCounter::report(const KURL& url, int live, int dead, size_t arenaSize) { String urlString = url; int totalTime = static_cast<int>((currentTime() - sStartTotalTime) * 1000); - int threadTime = get_thread_msec() - sStartThreadTime; + int threadTime = getThreadMsec() - sStartThreadTime; LOGD("*-* Total load time: %d ms, thread time: %d ms for %s\n", totalTime, threadTime, urlString.utf8().data()); for (Type type = (Type) 0; type < TotalTimeCounterCount; type @@ -132,7 +148,7 @@ void TimeCounter::report(const KURL& url, int live, int dead, size_t arenaSize) void TimeCounter::reportNow() { double current = currentTime(); - uint32_t currentThread = get_thread_msec(); + uint32_t currentThread = getThreadMsec(); int elapsedTime = static_cast<int>((current - sLastTotalTime) * 1000); int elapsedThreadTime = currentThread - sLastThreadTime; LOGD("*-* Elapsed time: %d ms, ui thread time: %d ms, webcore thread time:" @@ -162,12 +178,12 @@ void TimeCounter::reset() { bzero(sCounter, sizeof(sCounter)); LOGD("*-* Start browser instrument\n"); sStartTotalTime = currentTime(); - sStartThreadTime = get_thread_msec(); + sStartThreadTime = getThreadMsec(); } void TimeCounter::start(enum Type type) { - uint32_t time = get_thread_msec(); + uint32_t time = getThreadMsec(); if (sRecordWebCoreTime) { sStartWebCoreThreadTime = time; sRecordWebCoreTime = false; @@ -175,6 +191,6 @@ void TimeCounter::start(enum Type type) sStartTime[type] = time; } -#endif +#endif // ANDROID_INSTRUMENT } diff --git a/WebKit/android/TimeCounter.h b/WebKit/android/TimeCounter.h index 702aebf..64908d1 100644 --- a/WebKit/android/TimeCounter.h +++ b/WebKit/android/TimeCounter.h @@ -26,10 +26,7 @@ #ifndef TIME_COUNTER_H #define TIME_COUNTER_H -#ifdef ANDROID_INSTRUMENT - #include "hardware_legacy/qemu_tracing.h" -#include <wtf/CurrentTime.h> namespace WebCore { @@ -39,6 +36,10 @@ class KURL; namespace android { +uint32_t getThreadMsec(); + +#ifdef ANDROID_INSTRUMENT + class TimeCounter { public: enum Type { @@ -84,9 +85,9 @@ private: class TimeCounterAuto { public: TimeCounterAuto(TimeCounter::Type type) : - m_type(type), m_startTime(WTF::get_thread_msec()) {} + m_type(type), m_startTime(getThreadMsec()) {} ~TimeCounterAuto() { - uint32_t time = WTF::get_thread_msec(); + uint32_t time = getThreadMsec(); TimeCounter::sEndWebCoreThreadTime = time; TimeCounter::sTotalTimeUsed[m_type] += time - m_startTime; TimeCounter::sCounter[m_type]++; @@ -112,8 +113,8 @@ public: private: static int reentry_count; }; +#endif // ANDROID_INSTRUMENT } -#endif #endif diff --git a/WebKit/android/jni/PictureSet.cpp b/WebKit/android/jni/PictureSet.cpp index 3a5f9f2..22f57a3 100644 --- a/WebKit/android/jni/PictureSet.cpp +++ b/WebKit/android/jni/PictureSet.cpp @@ -36,7 +36,7 @@ #include "SkRect.h" #include "SkRegion.h" #include "SkStream.h" -#include <wtf/CurrentTime.h> +#include "TimeCounter.h" #define MAX_DRAW_TIME 100 #define MIN_SPLITTABLE 400 @@ -270,9 +270,9 @@ bool PictureSet::draw(SkCanvas* canvas) } canvas->translate(pathBounds.fLeft, pathBounds.fTop); canvas->save(); - uint32_t startTime = WTF::get_thread_msec(); + uint32_t startTime = getThreadMsec(); canvas->drawPicture(*working->mPicture); - size_t elapsed = working->mElapsed = WTF::get_thread_msec() - startTime; + size_t elapsed = working->mElapsed = getThreadMsec() - startTime; working->mWroteElapsed = true; if (maxElapsed < elapsed && (pathBounds.width() >= MIN_SPLITTABLE || pathBounds.height() >= MIN_SPLITTABLE)) |
