diff options
author | Chris Craik <ccraik@google.com> | 2011-08-19 17:35:20 -0700 |
---|---|---|
committer | Chris Craik <ccraik@google.com> | 2011-08-22 09:55:14 -0700 |
commit | 55ad2efde9465a03271495ac9f21acd121c3744c (patch) | |
tree | 93335892bf26c7fcf44f318e3be3efadaef56aad /tests/TileBenchmark | |
parent | 151763d3fc702ee2341aa6bebe821ce98d99e787 (diff) | |
download | frameworks_base-55ad2efde9465a03271495ac9f21acd121c3744c.zip frameworks_base-55ad2efde9465a03271495ac9f21acd121c3744c.tar.gz frameworks_base-55ad2efde9465a03271495ac9f21acd121c3744c.tar.bz2 |
Fix tile benchmark tool stalls
bug:5062896
Change-Id: I2969e95481d65d5f87ce4399f09becc7b66d540a
Diffstat (limited to 'tests/TileBenchmark')
4 files changed, 47 insertions, 22 deletions
diff --git a/tests/TileBenchmark/res/values/strings.xml b/tests/TileBenchmark/res/values/strings.xml index c4fd189..5af52dc 100644 --- a/tests/TileBenchmark/res/values/strings.xml +++ b/tests/TileBenchmark/res/values/strings.xml @@ -73,6 +73,8 @@ <string name="viewport_coverage">Coverage</string> <!-- Milliseconds taken to inval, and re-render the page [CHAR LIMIT=15] --> <string name="render_millis">RenderMillis</string> + <!-- Number of rendering stalls while running the test [CHAR LIMIT=15] --> + <string name="render_stalls">Stalls</string> <!-- Format string for stat value overlay [CHAR LIMIT=15] --> <string name="format_stat">%4.4f</string> diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java index 82a7e82..e7a21ad 100644 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java +++ b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java @@ -22,7 +22,6 @@ import android.content.Context; import android.graphics.Bitmap; import android.os.AsyncTask; import android.os.Bundle; -import android.os.CountDownTimer; import android.util.Pair; import android.view.KeyEvent; import android.view.View; @@ -55,8 +54,6 @@ public class ProfileActivity extends Activity { } public static final String TEMP_FILENAME = "profile.tiles"; - private static final int LOAD_TEST_DELAY = 1000; // nr of millis after load, - // before test Button mInspectButton; ToggleButton mCaptureButton; @@ -136,16 +133,7 @@ public class ProfileActivity extends Activity { super.onPageFinished(view, url); view.requestFocus(); - new CountDownTimer(LOAD_TEST_DELAY, LOAD_TEST_DELAY) { - @Override - public void onTick(long millisUntilFinished) { - } - - @Override - public void onFinish() { - startViewProfiling(true); - } - }.start(); + startViewProfiling(true); } @Override diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java index 3fc4665..b1cef15 100644 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java +++ b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java @@ -17,6 +17,7 @@ package com.test.tilebenchmark; import android.content.Context; +import android.os.CountDownTimer; import android.util.AttributeSet; import android.util.Log; import android.webkit.WebView; @@ -27,10 +28,14 @@ import com.test.tilebenchmark.RunData.TileData; public class ProfiledWebView extends WebView { private int mSpeed; - private boolean isTesting = false; - private boolean isScrolling = false; + private boolean mIsTesting = false; + private boolean mIsScrolling = false; private ProfileCallback mCallback; private long mContentInvalMillis; + private boolean mHadToBeForced = false; + private int mTestCount = 0; + private static final int LOAD_STALL_MILLIS = 5000; // nr of millis after load, + // before test is forced public ProfiledWebView(Context context) { super(context); @@ -51,12 +56,12 @@ public class ProfiledWebView extends WebView { @Override protected void onDraw(android.graphics.Canvas canvas) { - if (isTesting && isScrolling) { + if (mIsTesting && mIsScrolling) { if (canScrollVertically(1)) { scrollBy(0, mSpeed); } else { stopScrollTest(); - isScrolling = false; + mIsScrolling = false; } } super.onDraw(canvas); @@ -68,13 +73,36 @@ public class ProfiledWebView extends WebView { * scrolling, invalidate all content and redraw it, measuring time taken. */ public void startScrollTest(ProfileCallback callback, boolean autoScrolling) { - isScrolling = autoScrolling; + mIsScrolling = autoScrolling; mCallback = callback; - isTesting = false; + mIsTesting = false; mContentInvalMillis = System.currentTimeMillis(); registerPageSwapCallback(); contentInvalidateAll(); invalidate(); + + mTestCount++; + final int testCount = mTestCount; + + if (autoScrolling) { + // after a while, force it to start even if the pages haven't swapped + new CountDownTimer(LOAD_STALL_MILLIS, LOAD_STALL_MILLIS) { + @Override + public void onTick(long millisUntilFinished) { + } + + @Override + public void onFinish() { + if (testCount == mTestCount && !mIsTesting) { + mHadToBeForced = true; + Log.d("ProfiledWebView", "num " + testCount + + " forcing a page swap with a scroll..."); + scrollBy(0, 1); + invalidate(); // ensure a redraw so that auto-scrolling can occur + } + } + }.start(); + } } /* @@ -87,7 +115,7 @@ public class ProfiledWebView extends WebView { super.pageSwapCallback(); Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis + "millis"); - isTesting = true; + mIsTesting = true; invalidate(); // ensure a redraw so that auto-scrolling can occur tileProfilingStart(); } @@ -97,7 +125,7 @@ public class ProfiledWebView extends WebView { */ public void stopScrollTest() { tileProfilingStop(); - isTesting = false; + mIsTesting = false; if (mCallback == null) { tileProfilingClear(); @@ -105,8 +133,15 @@ public class ProfiledWebView extends WebView { } RunData data = new RunData(super.tileProfilingNumFrames()); + // record the time spent (before scrolling) rendering the page data.singleStats.put(getResources().getString(R.string.render_millis), (double)mContentInvalMillis); + // record if the page render timed out + Log.d("ProfiledWebView", "hadtobeforced = " + mHadToBeForced); + data.singleStats.put(getResources().getString(R.string.render_stalls), + mHadToBeForced ? 1.0 : 0.0); + mHadToBeForced = false; + for (int frame = 0; frame < data.frames.length; frame++) { data.frames[frame] = new TileData[ tileProfilingNumTilesInFrame(frame)]; diff --git a/tests/TileBenchmark/tests/src/com/test/tilebenchmark/PerformanceTest.java b/tests/TileBenchmark/tests/src/com/test/tilebenchmark/PerformanceTest.java index 0f02239..6bf6f6b 100644 --- a/tests/TileBenchmark/tests/src/com/test/tilebenchmark/PerformanceTest.java +++ b/tests/TileBenchmark/tests/src/com/test/tilebenchmark/PerformanceTest.java @@ -80,7 +80,7 @@ public class PerformanceTest extends private static final String URL_POSTFIX = "/index.html?skip=true"; private static final int MAX_ITERATIONS = 4; private static final String TEST_DIRS[] = { - "alexa_us"//, "android", "dom", "intl1", "intl2", "moz", "moz2" + "intl1"//, "alexa_us", "android", "dom", "intl2", "moz", "moz2" }; public PerformanceTest() { |