summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--JavaScriptCore/wtf/CurrentTime.cpp20
-rw-r--r--JavaScriptCore/wtf/CurrentTime.h4
-rw-r--r--WebKit/android/TimeCounter.cpp32
-rw-r--r--WebKit/android/TimeCounter.h13
-rw-r--r--WebKit/android/jni/PictureSet.cpp6
5 files changed, 34 insertions, 41 deletions
diff --git a/JavaScriptCore/wtf/CurrentTime.cpp b/JavaScriptCore/wtf/CurrentTime.cpp
index 6751995..b36cae5 100644
--- a/JavaScriptCore/wtf/CurrentTime.cpp
+++ b/JavaScriptCore/wtf/CurrentTime.cpp
@@ -290,24 +290,4 @@ double currentTime()
#endif
-#if PLATFORM(ANDROID)
-
-uint32_t get_thread_msec()
-{
-#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
-}
-
-#endif
-
} // namespace WTF
diff --git a/JavaScriptCore/wtf/CurrentTime.h b/JavaScriptCore/wtf/CurrentTime.h
index 436e054..31f1ec8 100644
--- a/JavaScriptCore/wtf/CurrentTime.h
+++ b/JavaScriptCore/wtf/CurrentTime.h
@@ -39,10 +39,6 @@ namespace WTF {
// than a millisecond.
double currentTime();
-#if PLATFORM(ANDROID)
- uint32_t get_thread_msec();
-#endif
-
} // namespace WTF
using WTF::currentTime;
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))