summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-05-16 10:03:17 -0700
committerJohn Reck <jreck@google.com>2011-05-16 15:56:50 -0700
commitd05cd8d73ef0b36cd415af17933fe79f9f8f328d (patch)
tree5743adcf2410a7de49a38d8b45b85d6a62fd089e
parenta6845ffdb3f9fd5eefb347185b141f7959000bac (diff)
downloadexternal_webkit-d05cd8d73ef0b36cd415af17933fe79f9f8f328d.zip
external_webkit-d05cd8d73ef0b36cd415af17933fe79f9f8f328d.tar.gz
external_webkit-d05cd8d73ef0b36cd415af17933fe79f9f8f328d.tar.bz2
Basic performance monitor for tiles
Change-Id: Ic67a5093a7c09b870ec34160ae0c999162dddcfc
-rw-r--r--Source/WebCore/Android.mk1
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.cpp59
-rw-r--r--Source/WebCore/platform/graphics/android/BaseTile.h3
-rw-r--r--Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp81
-rw-r--r--Source/WebCore/platform/graphics/android/PerformanceMonitor.h58
5 files changed, 200 insertions, 2 deletions
diff --git a/Source/WebCore/Android.mk b/Source/WebCore/Android.mk
index a0e56de..102b401 100644
--- a/Source/WebCore/Android.mk
+++ b/Source/WebCore/Android.mk
@@ -632,6 +632,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
platform/graphics/android/PathAndroid.cpp \
platform/graphics/android/PatternAndroid.cpp \
platform/graphics/android/PlatformGraphicsContext.cpp \
+ platform/graphics/android/PerformanceMonitor.cpp \
platform/graphics/android/ScrollableLayerAndroid.cpp \
platform/graphics/android/SharedBufferStream.cpp \
platform/graphics/android/ShaderProgram.cpp \
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.cpp b/Source/WebCore/platform/graphics/android/BaseTile.cpp
index c74a278..03f180e 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.cpp
+++ b/Source/WebCore/platform/graphics/android/BaseTile.cpp
@@ -40,12 +40,12 @@
#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>
#include <cutils/atomic.h>
+#include <wtf/text/CString.h>
#ifdef DEBUG
#include <cutils/log.h>
#include <wtf/CurrentTime.h>
-#include <wtf/text/CString.h>
#undef XLOG
#define XLOG(...) android_printLog(ANDROID_LOG_DEBUG, "BaseTile", __VA_ARGS__)
@@ -59,6 +59,20 @@
namespace WebCore {
+static const String TAG_CREATE_BITMAP = "create_bitmap";
+static const String TAG_RECORD_PICTURE = "record_picture";
+static const String TAG_DRAW_PICTURE = "draw_picture";
+static const String TAG_UPDATE_TEXTURE = "update_texture";
+static const String TAG_RESET_BITMAP = "reset_bitmap";
+#define TAG_COUNT 5
+static const String TAGS[] = {
+ TAG_CREATE_BITMAP,
+ TAG_RECORD_PICTURE,
+ TAG_DRAW_PICTURE,
+ TAG_UPDATE_TEXTURE,
+ TAG_RESET_BITMAP
+};
+
BaseTile::BaseTile()
: m_page(0)
, m_x(-1)
@@ -264,6 +278,23 @@ void BaseTile::drawTileInfo(SkCanvas* canvas,
canvas->drawText(str, strlen(str), 0, 10, paint);
paint.setARGB(255, 255, 0, 0);
canvas->drawText(str, strlen(str), 0, 11, paint);
+ float total = 0;
+ for (int i = 0; i < TAG_COUNT; i++) {
+ float tagDuration = m_perfMon.getAverageDuration(TAGS[i]);
+ total += tagDuration;
+ snprintf(str, 256, "%s: %.2f", TAGS[i].utf8().data(), tagDuration);
+ paint.setARGB(255, 0, 0, 0);
+ int textY = (i * 12) + 25;
+ canvas->drawText(str, strlen(str), 0, textY, paint);
+ paint.setARGB(255, 255, 0, 0);
+ canvas->drawText(str, strlen(str), 0, textY + 1, paint);
+ }
+ snprintf(str, 256, "total: %.2f", total);
+ paint.setARGB(255, 0, 0, 0);
+ int textY = (TAG_COUNT * 12) + 30;
+ canvas->drawText(str, strlen(str), 0, textY, paint);
+ paint.setARGB(255, 255, 0, 0);
+ canvas->drawText(str, strlen(str), 0, textY + 1, paint);
}
// This is called from the texture generation thread
@@ -432,7 +463,11 @@ int BaseTile::paintPartialBitmap(SkIRect r, float ptx, float pty,
tx = - x() * TilesManager::instance()->tileWidth() / scale;
ty = - y() * TilesManager::instance()->tileHeight() / scale;
}
+ bool visualIndicator = TilesManager::instance()->getShowVisualIndicator();
+ bool measurePerf = fullRepaint && visualIndicator;
+ if (measurePerf)
+ m_perfMon.start(TAG_CREATE_BITMAP);
SkBitmap bitmap;
bitmap.setConfig(SkBitmap::kARGB_8888_Config, rect.width(), rect.height());
bitmap.allocPixels();
@@ -441,6 +476,10 @@ int BaseTile::paintPartialBitmap(SkIRect r, float ptx, float pty,
SkCanvas canvas(bitmap);
canvas.drawARGB(255, 255, 255, 255);
+ if (measurePerf) {
+ m_perfMon.stop(TAG_CREATE_BITMAP);
+ m_perfMon.start(TAG_RECORD_PICTURE);
+ }
SkPicture picture;
SkCanvas* nCanvas = picture.beginRecording(rect.width(), rect.height());
nCanvas->scale(scale, scale);
@@ -448,12 +487,18 @@ int BaseTile::paintPartialBitmap(SkIRect r, float ptx, float pty,
int pictureCount = tiledPage->paintBaseLayerContent(nCanvas);
picture.endRecording();
- bool visualIndicator = TilesManager::instance()->getShowVisualIndicator();
+ if (measurePerf) {
+ m_perfMon.stop(TAG_RECORD_PICTURE);
+ m_perfMon.start(TAG_DRAW_PICTURE);
+ }
if (visualIndicator)
canvas.save();
picture.draw(&canvas);
if (visualIndicator)
canvas.restore();
+ if (measurePerf) {
+ m_perfMon.stop(TAG_DRAW_PICTURE);
+ }
if (visualIndicator) {
int color = 20 + pictureCount % 100;
@@ -477,11 +522,21 @@ int BaseTile::paintPartialBitmap(SkIRect r, float ptx, float pty,
textureInfo->m_width = rect.width();
textureInfo->m_height = rect.height();
} else {
+ if (measurePerf)
+ m_perfMon.start(TAG_UPDATE_TEXTURE);
GLUtils::updateTextureWithBitmap(textureInfo->m_textureId, rect.fLeft, rect.fTop, bitmap);
+ if (measurePerf)
+ m_perfMon.stop(TAG_UPDATE_TEXTURE);
}
+ if (measurePerf)
+ m_perfMon.start(TAG_RESET_BITMAP);
+
bitmap.reset();
+ if (measurePerf)
+ m_perfMon.stop(TAG_RESET_BITMAP);
+
return pictureCount;
}
diff --git a/Source/WebCore/platform/graphics/android/BaseTile.h b/Source/WebCore/platform/graphics/android/BaseTile.h
index 7b28f76..03b96ce 100644
--- a/Source/WebCore/platform/graphics/android/BaseTile.h
+++ b/Source/WebCore/platform/graphics/android/BaseTile.h
@@ -29,6 +29,7 @@
#if USE(ACCELERATED_COMPOSITING)
#include "HashMap.h"
+#include "PerformanceMonitor.h"
#include "SharedTexture.h"
#include "SkBitmap.h"
#include "SkCanvas.h"
@@ -143,6 +144,8 @@ private:
// across all threads and cores.
android::Mutex m_atomicSync;
+ // Performance tracking
+ PerformanceMonitor m_perfMon;
};
} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp b/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp
new file mode 100644
index 0000000..20d1299
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/PerformanceMonitor.cpp
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "PerformanceMonitor.h"
+
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+PerformanceMonitor::PerformanceMonitor()
+{
+}
+
+PerformanceMonitor::~PerformanceMonitor()
+{
+}
+
+void PerformanceMonitor::start(const String &tag)
+{
+ if (tag.isEmpty())
+ return;
+ PerfItem *item;
+ if (m_tags.contains(tag))
+ item = m_tags.get(tag);
+ else {
+ item = new PerfItem();
+ m_tags.set(tag, item);
+ }
+ gettimeofday(&(item->start_time), NULL);
+}
+
+void PerformanceMonitor::stop(const String &tag)
+{
+ if (!m_tags.contains(tag))
+ return;
+ PerfItem *item = m_tags.get(tag);
+ struct timeval end;
+ gettimeofday(&end, NULL);
+ long seconds, useconds;
+ seconds = end.tv_sec - item->start_time.tv_sec;
+ useconds = end.tv_usec - item->start_time.tv_usec;
+
+ float mtime = (seconds * 1000.0) + (useconds/1000.0);
+
+ float avg = 0;
+ if (item->average_ms) {
+ item->average_ms = (item->average_ms + mtime) / 2;
+ } else
+ item->average_ms = mtime;
+}
+
+float PerformanceMonitor::getAverageDuration(const String &tag)
+{
+ if (tag.isEmpty() || !m_tags.contains(tag))
+ return 0;
+ return m_tags.get(tag)->average_ms;
+}
+
+} // namespace WebCore
diff --git a/Source/WebCore/platform/graphics/android/PerformanceMonitor.h b/Source/WebCore/platform/graphics/android/PerformanceMonitor.h
new file mode 100644
index 0000000..4c3afd1
--- /dev/null
+++ b/Source/WebCore/platform/graphics/android/PerformanceMonitor.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2011, The Android Open Source Project
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef PERFORMANCEMONITOR_H_
+#define PERFORMANCEMONITOR_H_
+
+#include "config.h"
+
+#include <wtf/HashMap.h>
+#include <wtf/text/StringHash.h>
+#include <sys/time.h>
+#include <unistd.h>
+
+namespace WebCore {
+
+struct PerfItem {
+ PerfItem() : average_ms(0), start_time() {}
+ float average_ms;
+ struct timeval start_time;
+};
+
+class PerformanceMonitor {
+public:
+ PerformanceMonitor();
+ virtual ~PerformanceMonitor();
+ void start(const String &tag);
+ void stop(const String &tag);
+ float getAverageDuration(const String &tag);
+
+private:
+ HashMap<String, PerfItem*, StringHash> m_tags;
+};
+
+}
+
+#endif /* PERFORMANCEMONITOR_H_ */