diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-06 10:29:41 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-07-06 10:29:41 -0700 |
commit | ae596082b5e2c6f7e0ad6535bea08d3f22b7c97f (patch) | |
tree | d025f52939478462c381a31c6ec2a580937a4867 | |
parent | 9bd224481ef2ba73ef3f3fe0fe8e34a8a7d5a901 (diff) | |
parent | f099481c26a412b8193847b4c1a145c9f2d59aba (diff) | |
download | frameworks_base-ae596082b5e2c6f7e0ad6535bea08d3f22b7c97f.zip frameworks_base-ae596082b5e2c6f7e0ad6535bea08d3f22b7c97f.tar.gz frameworks_base-ae596082b5e2c6f7e0ad6535bea08d3f22b7c97f.tar.bz2 |
Merge change 6159
* changes:
Add the code to detect how long the WebViewCore thread is idle in the real time.
-rw-r--r-- | core/java/android/webkit/CallbackProxy.java | 44 |
1 files changed, 41 insertions, 3 deletions
diff --git a/core/java/android/webkit/CallbackProxy.java b/core/java/android/webkit/CallbackProxy.java index 9a8c3c0..3b67fb6 100644 --- a/core/java/android/webkit/CallbackProxy.java +++ b/core/java/android/webkit/CallbackProxy.java @@ -641,7 +641,40 @@ class CallbackProxy extends Handler { //-------------------------------------------------------------------------- // Performance probe + private static final boolean PERF_PROBE = false; private long mWebCoreThreadTime; + private long mWebCoreIdleTime; + + /* + * If PERF_PROBE is true, this block needs to be added to MessageQueue.java. + * startWait() and finishWait() should be called before and after wait(). + + private WaitCallback mWaitCallback = null; + public static interface WaitCallback { + void startWait(); + void finishWait(); + } + public final void setWaitCallback(WaitCallback callback) { + mWaitCallback = callback; + } + */ + + // un-comment this block if PERF_PROBE is true + /* + private IdleCallback mIdleCallback = new IdleCallback(); + + private final class IdleCallback implements MessageQueue.WaitCallback { + private long mStartTime = 0; + + public void finishWait() { + mWebCoreIdleTime += SystemClock.uptimeMillis() - mStartTime; + } + + public void startWait() { + mStartTime = SystemClock.uptimeMillis(); + } + } + */ public void onPageStarted(String url, Bitmap favicon) { // Do an unsynchronized quick check to avoid posting if no callback has @@ -650,9 +683,12 @@ class CallbackProxy extends Handler { return; } // Performance probe - if (false) { + if (PERF_PROBE) { mWebCoreThreadTime = SystemClock.currentThreadTimeMillis(); + mWebCoreIdleTime = 0; Network.getInstance(mContext).startTiming(); + // un-comment this if PERF_PROBE is true +// Looper.myQueue().setWaitCallback(mIdleCallback); } Message msg = obtainMessage(PAGE_STARTED); msg.obj = favicon; @@ -667,10 +703,12 @@ class CallbackProxy extends Handler { return; } // Performance probe - if (false) { + if (PERF_PROBE) { + // un-comment this if PERF_PROBE is true +// Looper.myQueue().setWaitCallback(null); Log.d("WebCore", "WebCore thread used " + (SystemClock.currentThreadTimeMillis() - mWebCoreThreadTime) - + " ms"); + + " ms and idled " + mWebCoreIdleTime + " ms"); Network.getInstance(mContext).stopTiming(); } Message msg = obtainMessage(PAGE_FINISHED, url); |