diff options
author | Jonathan Dixon <joth@google.com> | 2013-08-25 22:46:49 -0700 |
---|---|---|
committer | Jonathan Dixon <joth@google.com> | 2013-08-25 22:54:21 -0700 |
commit | ada3dbe7c98e44ed350e83cad62eb9f410bbc0f2 (patch) | |
tree | 962068388705808577fbb3d6c849f662f74af6db /tests/TileBenchmark | |
parent | 94366313331a789440a3c077173aafcb85cabe78 (diff) | |
download | frameworks_base-ada3dbe7c98e44ed350e83cad62eb9f410bbc0f2.zip frameworks_base-ada3dbe7c98e44ed350e83cad62eb9f410bbc0f2.tar.gz frameworks_base-ada3dbe7c98e44ed350e83cad62eb9f410bbc0f2.tar.bz2 |
Remove WebViewClassic specific test code
Bug: 10427705
These tested internals of WebViewClassic and will no longer build when
that is removed
Change-Id: I42af538dcb0343e9eff0b3fa85d7ff39f19c7c61
Diffstat (limited to 'tests/TileBenchmark')
7 files changed, 0 insertions, 1666 deletions
diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/PerformanceTest.java b/tests/TileBenchmark/src/com/test/tilebenchmark/PerformanceTest.java deleted file mode 100644 index 5763ad3..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/PerformanceTest.java +++ /dev/null @@ -1,320 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import com.test.tilebenchmark.ProfileActivity.ProfileCallback; - -import java.io.File; -import java.util.HashMap; -import java.util.Map; - -import android.content.res.Resources; -import android.os.Bundle; -import android.os.Environment; -import android.test.ActivityInstrumentationTestCase2; -import android.util.Log; -import android.webkit.WebSettings; -import android.widget.Spinner; - -public class PerformanceTest extends - ActivityInstrumentationTestCase2<ProfileActivity> { - - public static class AnimStat { - double aggVal = 0; - double aggSqrVal = 0; - double count = 0; - } - - private class StatAggregator extends PlaybackGraphs { - private HashMap<String, Double> mDataMap = new HashMap<String, Double>(); - private HashMap<String, AnimStat> mAnimDataMap = new HashMap<String, AnimStat>(); - private int mCount = 0; - - - public void aggregate() { - boolean inAnimTests = mAnimTests != null; - Resources resources = mWeb.getResources(); - String animFramerateString = resources.getString(R.string.animation_framerate); - for (Map.Entry<String, Double> e : mSingleStats.entrySet()) { - String name = e.getKey(); - if (inAnimTests) { - if (name.equals(animFramerateString)) { - // in animation testing phase, record animation framerate and aggregate - // stats, differentiating on values of mAnimTestNr and mDoubleBuffering - String fullName = ANIM_TEST_NAMES[mAnimTestNr] + " " + name; - fullName += mDoubleBuffering ? " tiled" : " webkit"; - - if (!mAnimDataMap.containsKey(fullName)) { - mAnimDataMap.put(fullName, new AnimStat()); - } - AnimStat statVals = mAnimDataMap.get(fullName); - statVals.aggVal += e.getValue(); - statVals.aggSqrVal += e.getValue() * e.getValue(); - statVals.count += 1; - } - } else { - double aggVal = mDataMap.containsKey(name) - ? mDataMap.get(name) : 0; - mDataMap.put(name, aggVal + e.getValue()); - } - } - - if (inAnimTests) { - return; - } - - mCount++; - for (int metricIndex = 0; metricIndex < Metrics.length; metricIndex++) { - for (int statIndex = 0; statIndex < Stats.length; statIndex++) { - String metricLabel = resources.getString( - Metrics[metricIndex].getLabelId()); - String statLabel = resources.getString( - Stats[statIndex].getLabelId()); - - String label = metricLabel + " " + statLabel; - double aggVal = mDataMap.containsKey(label) ? mDataMap - .get(label) : 0; - - aggVal += mStats[metricIndex][statIndex]; - mDataMap.put(label, aggVal); - } - } - - } - - // build the final bundle of results - public Bundle getBundle() { - Bundle b = new Bundle(); - int count = (0 == mCount) ? Integer.MAX_VALUE : mCount; - for (Map.Entry<String, Double> e : mDataMap.entrySet()) { - b.putDouble(e.getKey(), e.getValue() / count); - } - - for (Map.Entry<String, AnimStat> e : mAnimDataMap.entrySet()) { - String statName = e.getKey(); - AnimStat statVals = e.getValue(); - - double avg = statVals.aggVal/statVals.count; - double stdDev = Math.sqrt((statVals.aggSqrVal / statVals.count) - avg * avg); - - b.putDouble(statName, avg); - b.putDouble(statName + " STD DEV", stdDev); - } - - return b; - } - } - - ProfileActivity mActivity; - ProfiledWebView mWeb; - Spinner mMovementSpinner; - StatAggregator mStats; - - private static final String LOGTAG = "PerformanceTest"; - private static final String TEST_LOCATION = "webkit/page_cycler"; - private static final String URL_PREFIX = "file://"; - private static final String URL_POSTFIX = "/index.html?skip=true"; - private static final int MAX_ITERATIONS = 4; - private static final String SCROLL_TEST_DIRS[] = { - "alexa25_2011" - }; - private static final String ANIM_TEST_DIRS[] = { - "dhtml" - }; - - public PerformanceTest() { - super(ProfileActivity.class); - } - - @Override - protected void setUp() throws Exception { - super.setUp(); - mActivity = getActivity(); - mWeb = (ProfiledWebView) mActivity.findViewById(R.id.web); - mMovementSpinner = (Spinner) mActivity.findViewById(R.id.movement); - mStats = new StatAggregator(); - - // use mStats as a condition variable between the UI thread and - // this(the testing) thread - mActivity.setCallback(new ProfileCallback() { - @Override - public void profileCallback(RunData data) { - mStats.setData(data); - synchronized (mStats) { - mStats.notify(); - } - } - }); - - } - - private boolean loadUrl(final String url) { - try { - Log.d(LOGTAG, "test starting for url " + url); - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mWeb.loadUrl(url); - } - }); - synchronized (mStats) { - mStats.wait(); - } - - mStats.aggregate(); - } catch (InterruptedException e) { - e.printStackTrace(); - return false; - } - return true; - } - - private boolean validTest(String nextTest) { - // if testing animations, test must be in mAnimTests - if (mAnimTests == null) - return true; - - for (String test : mAnimTests) { - if (test.equals(nextTest)) { - return true; - } - } - return false; - } - - private boolean runIteration(String[] testDirs) { - File sdFile = Environment.getExternalStorageDirectory(); - for (String testDirName : testDirs) { - File testDir = new File(sdFile, TEST_LOCATION + "/" + testDirName); - Log.d(LOGTAG, "Testing dir: '" + testDir.getAbsolutePath() - + "', exists=" + testDir.exists()); - - for (File siteDir : testDir.listFiles()) { - if (!siteDir.isDirectory() || !validTest(siteDir.getName())) { - continue; - } - - if (!loadUrl(URL_PREFIX + siteDir.getAbsolutePath() - + URL_POSTFIX)) { - return false; - } - } - } - return true; - } - - private boolean runTestDirs(String[] testDirs) { - for (int i = 0; i < MAX_ITERATIONS; i++) - if (!runIteration(testDirs)) { - return false; - } - return true; - } - - private void pushDoubleBuffering() { - getInstrumentation().runOnMainSync(new Runnable() { - public void run() { - mWeb.setDoubleBuffering(mDoubleBuffering); - } - }); - } - - private void setScrollingTestingMode(final boolean scrolled) { - getInstrumentation().runOnMainSync(new Runnable() { - public void run() { - mMovementSpinner.setSelection(scrolled ? 0 : 2); - } - }); - } - - - private String[] mAnimTests = null; - private int mAnimTestNr = -1; - private boolean mDoubleBuffering = true; - private static final String[] ANIM_TEST_NAMES = { - "slow", "fast" - }; - private static final String[][] ANIM_TESTS = { - {"scrolling", "replaceimages", "layers5", "layers1"}, - {"slidingballs", "meter", "slidein", "fadespacing", "colorfade", - "mozilla", "movingtext", "diagball", "zoom", "imageslide"}, - }; - - private boolean checkMedia() { - String state = Environment.getExternalStorageState(); - - if (!Environment.MEDIA_MOUNTED.equals(state) - && !Environment.MEDIA_MOUNTED_READ_ONLY.equals(state)) { - Log.d(LOGTAG, "ARG Can't access sd card!"); - // Can't read the SD card, fail and die! - getInstrumentation().sendStatus(1, null); - return false; - } - return true; - } - - public void testMetrics() { - setScrollingTestingMode(true); - if (checkMedia() && runTestDirs(SCROLL_TEST_DIRS)) { - getInstrumentation().sendStatus(0, mStats.getBundle()); - } else { - getInstrumentation().sendStatus(1, null); - } - } - - public void testMetricsMinimalMemory() { - mActivity.runOnUiThread(new Runnable() { - @Override - public void run() { - mWeb.setUseMinimalMemory(true); - } - }); - - setScrollingTestingMode(true); - if (checkMedia() && runTestDirs(SCROLL_TEST_DIRS)) { - getInstrumentation().sendStatus(0, mStats.getBundle()); - } else { - getInstrumentation().sendStatus(1, null); - } - } - - private boolean runAnimationTests() { - for (int doubleBuffer = 0; doubleBuffer <= 1; doubleBuffer++) { - mDoubleBuffering = doubleBuffer == 1; - pushDoubleBuffering(); - for (mAnimTestNr = 0; mAnimTestNr < ANIM_TESTS.length; mAnimTestNr++) { - mAnimTests = ANIM_TESTS[mAnimTestNr]; - if (!runTestDirs(ANIM_TEST_DIRS)) { - return false; - } - } - } - return true; - } - - public void testAnimations() { - // instead of autoscrolling, load each page until either an timer fires, - // or the animation signals complete via javascript - setScrollingTestingMode(false); - - if (checkMedia() && runAnimationTests()) { - getInstrumentation().sendStatus(0, mStats.getBundle()); - } else { - getInstrumentation().sendStatus(1, null); - } - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackActivity.java b/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackActivity.java deleted file mode 100644 index 1eb1c00..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackActivity.java +++ /dev/null @@ -1,173 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import android.app.Activity; -import android.os.AsyncTask; -import android.os.Bundle; -import android.view.GestureDetector.SimpleOnGestureListener; -import android.view.MotionEvent; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.SeekBar; -import android.widget.SeekBar.OnSeekBarChangeListener; -import android.widget.TextView; -import android.widget.Toast; - -import java.io.FileInputStream; -import java.io.IOException; -import java.io.ObjectInputStream; - -/** - * Interface for playing back WebView tile rendering status. Draws viewport and - * states of tiles and statistics for off-line analysis. - */ -public class PlaybackActivity extends Activity { - private static final float SCROLL_SCALER = 0.125f; - - PlaybackView mPlaybackView; - SeekBar mSeekBar; - Button mForward; - Button mBackward; - TextView mFrameDisplay; - - private int mFrame = -1; - private int mFrameMax; - - private class TouchFrameChangeListener extends SimpleOnGestureListener { - float mDist = 0; - - @Override - public boolean onScroll(MotionEvent e1, MotionEvent e2, - float distanceX, float distanceY) { - // aggregate scrolls so that small ones can add up - mDist += distanceY * SCROLL_SCALER; - int intComponent = (int) Math.floor(Math.abs(mDist)); - if (intComponent >= 1) { - int scrollDist = (mDist > 0) ? intComponent : -intComponent; - setFrame(null, mFrame + scrollDist); - mDist -= scrollDist; - } - return super.onScroll(e1, e2, distanceX, distanceY); - } - }; - - private class SeekFrameChangeListener implements OnSeekBarChangeListener { - @Override - public void onStopTrackingTouch(SeekBar seekBar) { - } - - @Override - public void onStartTrackingTouch(SeekBar seekBar) { - } - - @Override - public void onProgressChanged(SeekBar seekBar, int progress, - boolean fromUser) { - setFrame(seekBar, progress); - } - }; - - private class LoadFileTask extends AsyncTask<String, Void, RunData> { - @Override - protected RunData doInBackground(String... params) { - RunData data = null; - try { - FileInputStream fis = openFileInput(params[0]); - ObjectInputStream in = new ObjectInputStream(fis); - data = (RunData) in.readObject(); - in.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } catch (ClassNotFoundException ex) { - ex.printStackTrace(); - } - return data; - } - - @Override - protected void onPostExecute(RunData data) { - if (data == null) { - Toast.makeText(getApplicationContext(), - getResources().getString(R.string.error_no_data), - Toast.LENGTH_LONG).show(); - return; - } - mPlaybackView.setData(data); - - mFrameMax = data.frames.length - 1; - mSeekBar.setMax(mFrameMax); - - setFrame(null, 0); - } - } - - private void setFrame(View changer, int f) { - if (f < 0) { - f = 0; - } else if (f > mFrameMax) { - f = mFrameMax; - } - - if (mFrame == f) { - return; - } - - mFrame = f; - mForward.setEnabled(mFrame != mFrameMax); - mBackward.setEnabled(mFrame != 0); - if (changer != mSeekBar) { - mSeekBar.setProgress(mFrame); - } - mFrameDisplay.setText(Integer.toString(mFrame)); - mPlaybackView.setFrame(mFrame); - }; - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.playback); - - mPlaybackView = (PlaybackView) findViewById(R.id.playback); - mSeekBar = (SeekBar) findViewById(R.id.seek_bar); - mForward = (Button) findViewById(R.id.forward); - mBackward = (Button) findViewById(R.id.backward); - mFrameDisplay = (TextView) findViewById(R.id.frame_display); - - mForward.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - setFrame(v, mFrame + 1); - } - }); - - mBackward.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - setFrame(v, mFrame - 1); - } - }); - - mSeekBar.setOnSeekBarChangeListener(new SeekFrameChangeListener()); - - mPlaybackView.setOnGestureListener(new TouchFrameChangeListener()); - - new LoadFileTask().execute(ProfileActivity.TEMP_FILENAME); - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackGraphs.java b/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackGraphs.java deleted file mode 100644 index 065e86f..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackGraphs.java +++ /dev/null @@ -1,306 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import android.content.res.Resources; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.Rect; -import android.graphics.drawable.ShapeDrawable; - -import com.test.tilebenchmark.RunData.TileData; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashMap; - -public class PlaybackGraphs { - private static final int BAR_WIDTH = PlaybackView.TILE_SCALE * 3; - private static final float CANVAS_SCALE = 0.2f; - private static final double IDEAL_FRAMES = 60; - private static final int LABELOFFSET = 100; - private static Paint whiteLabels; - - private static double viewportCoverage(TileData view, TileData tile) { - if (tile.left < (view.right * view.scale) - && tile.right >= (view.left * view.scale) - && tile.top < (view.bottom * view.scale) - && tile.bottom >= (view.top * view.scale)) { - return 1.0f; - } - return 0.0f; - } - - protected interface MetricGen { - public double getValue(TileData[] frame); - - public double getMax(); - - public int getLabelId(); - }; - - protected static MetricGen[] Metrics = new MetricGen[] { - new MetricGen() { - // framerate graph - @Override - public double getValue(TileData[] frame) { - int renderTimeUS = frame[0].level; - return 1.0e6f / renderTimeUS; - } - - @Override - public double getMax() { - return IDEAL_FRAMES; - } - - @Override - public int getLabelId() { - return R.string.frames_per_second; - } - }, new MetricGen() { - // coverage graph - @Override - public double getValue(TileData[] frame) { - double total = 0, totalCount = 0; - for (int tileID = 1; tileID < frame.length; tileID++) { - TileData data = frame[tileID]; - double coverage = viewportCoverage(frame[0], data); - total += coverage * (data.isReady ? 100 : 0); - totalCount += coverage; - } - if (totalCount == 0) { - return -1; - } - return total / totalCount; - } - - @Override - public double getMax() { - return 100; - } - - @Override - public int getLabelId() { - return R.string.viewport_coverage; - } - } - }; - - protected interface StatGen { - public double getValue(double sortedValues[]); - - public int getLabelId(); - } - - public static double getPercentile(double sortedValues[], double ratioAbove) { - if (sortedValues.length == 0) - return -1; - - double index = ratioAbove * (sortedValues.length - 1); - int intIndex = (int) Math.floor(index); - if (index == intIndex) { - return sortedValues[intIndex]; - } - double alpha = index - intIndex; - return sortedValues[intIndex] * (1 - alpha) - + sortedValues[intIndex + 1] * (alpha); - } - - public static double getMean(double sortedValues[]) { - if (sortedValues.length == 0) - return -1; - - double agg = 0; - for (double val : sortedValues) { - agg += val; - } - return agg / sortedValues.length; - } - - public static double getStdDev(double sortedValues[]) { - if (sortedValues.length == 0) - return -1; - - double agg = 0; - double sqrAgg = 0; - for (double val : sortedValues) { - agg += val; - sqrAgg += val*val; - } - double mean = agg / sortedValues.length; - return Math.sqrt((sqrAgg / sortedValues.length) - (mean * mean)); - } - - protected static StatGen[] Stats = new StatGen[] { - new StatGen() { - @Override - public double getValue(double[] sortedValues) { - return getPercentile(sortedValues, 0.25); - } - - @Override - public int getLabelId() { - return R.string.percentile_25; - } - }, new StatGen() { - @Override - public double getValue(double[] sortedValues) { - return getPercentile(sortedValues, 0.5); - } - - @Override - public int getLabelId() { - return R.string.percentile_50; - } - }, new StatGen() { - @Override - public double getValue(double[] sortedValues) { - return getPercentile(sortedValues, 0.75); - } - - @Override - public int getLabelId() { - return R.string.percentile_75; - } - }, new StatGen() { - @Override - public double getValue(double[] sortedValues) { - return getStdDev(sortedValues); - } - - @Override - public int getLabelId() { - return R.string.std_dev; - } - }, new StatGen() { - @Override - public double getValue(double[] sortedValues) { - return getMean(sortedValues); - } - - @Override - public int getLabelId() { - return R.string.mean; - } - }, - }; - - public PlaybackGraphs() { - whiteLabels = new Paint(); - whiteLabels.setColor(Color.WHITE); - whiteLabels.setTextSize(PlaybackView.TILE_SCALE / 3); - } - - private ArrayList<ShapeDrawable> mShapes = new ArrayList<ShapeDrawable>(); - protected final double[][] mStats = new double[Metrics.length][Stats.length]; - protected HashMap<String, Double> mSingleStats; - - private void gatherFrameMetric(int metricIndex, double metricValues[], RunData data) { - // create graph out of rectangles, one per frame - int lastBar = 0; - for (int frameIndex = 0; frameIndex < data.frames.length; frameIndex++) { - TileData frame[] = data.frames[frameIndex]; - int newBar = (int)((frame[0].top + frame[0].bottom) * frame[0].scale / 2.0f); - - MetricGen s = Metrics[metricIndex]; - double absoluteValue = s.getValue(frame); - double relativeValue = absoluteValue / s.getMax(); - relativeValue = Math.min(1,relativeValue); - relativeValue = Math.max(0,relativeValue); - int rightPos = (int) (-BAR_WIDTH * metricIndex); - int leftPos = (int) (-BAR_WIDTH * (metricIndex + relativeValue)); - - ShapeDrawable graphBar = new ShapeDrawable(); - graphBar.getPaint().setColor(Color.BLUE); - graphBar.setBounds(leftPos, lastBar, rightPos, newBar); - - mShapes.add(graphBar); - metricValues[frameIndex] = absoluteValue; - lastBar = newBar; - } - } - - public void setData(RunData data) { - mShapes.clear(); - double metricValues[] = new double[data.frames.length]; - - mSingleStats = data.singleStats; - - if (data.frames.length == 0) { - return; - } - - for (int metricIndex = 0; metricIndex < Metrics.length; metricIndex++) { - // calculate metric based on list of frames - gatherFrameMetric(metricIndex, metricValues, data); - - // store aggregate statistics per metric (median, and similar) - Arrays.sort(metricValues); - for (int statIndex = 0; statIndex < Stats.length; statIndex++) { - mStats[metricIndex][statIndex] = - Stats[statIndex].getValue(metricValues); - } - } - } - - public void drawVerticalShiftedShapes(Canvas canvas, - ArrayList<ShapeDrawable> shapes) { - // Shapes drawn here are drawn relative to the viewRect - Rect viewRect = shapes.get(shapes.size() - 1).getBounds(); - canvas.translate(0, 5 * PlaybackView.TILE_SCALE - viewRect.top); - - for (ShapeDrawable shape : mShapes) { - shape.draw(canvas); - } - for (ShapeDrawable shape : shapes) { - shape.draw(canvas); - } - } - - public void draw(Canvas canvas, ArrayList<ShapeDrawable> shapes, - ArrayList<String> strings, Resources resources) { - canvas.scale(CANVAS_SCALE, CANVAS_SCALE); - - canvas.translate(BAR_WIDTH * Metrics.length, 0); - - canvas.save(); - drawVerticalShiftedShapes(canvas, shapes); - canvas.restore(); - - for (int metricIndex = 0; metricIndex < Metrics.length; metricIndex++) { - String label = resources.getString( - Metrics[metricIndex].getLabelId()); - int xPos = (metricIndex + 1) * -BAR_WIDTH; - int yPos = LABELOFFSET; - canvas.drawText(label, xPos, yPos, whiteLabels); - for (int statIndex = 0; statIndex < Stats.length; statIndex++) { - String statLabel = resources.getString( - Stats[statIndex].getLabelId()).substring(0,3); - label = statLabel + " " + resources.getString( - R.string.format_stat, mStats[metricIndex][statIndex]); - yPos = LABELOFFSET + (1 + statIndex) * PlaybackView.TILE_SCALE - / 2; - canvas.drawText(label, xPos, yPos, whiteLabels); - } - } - for (int stringIndex = 0; stringIndex < strings.size(); stringIndex++) { - int yPos = LABELOFFSET + stringIndex * PlaybackView.TILE_SCALE / 2; - canvas.drawText(strings.get(stringIndex), 0, yPos, whiteLabels); - } - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackView.java b/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackView.java deleted file mode 100644 index 5459c1f..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/PlaybackView.java +++ /dev/null @@ -1,224 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import android.animation.ArgbEvaluator; -import android.animation.ObjectAnimator; -import android.animation.ValueAnimator; -import android.content.Context; -import android.graphics.Canvas; -import android.graphics.Color; -import android.graphics.Paint; -import android.graphics.drawable.ShapeDrawable; -import android.util.AttributeSet; -import android.view.GestureDetector; -import android.view.GestureDetector.OnGestureListener; -import android.view.MotionEvent; -import android.view.View; - -import com.test.tilebenchmark.RunData.TileData; - -import java.util.ArrayList; - -public class PlaybackView extends View { - public static final int TILE_SCALE = 256; - private static final int INVAL_FLAG = -2; - private static final int INVAL_CYCLE = 250; - - private Paint levelPaint = null, coordPaint = null, goldPaint = null; - private PlaybackGraphs mGraphs; - - private ArrayList<ShapeDrawable> mTempShapes = new ArrayList<ShapeDrawable>(); - private RunData mProfData = null; - private GestureDetector mGestureDetector = null; - private ArrayList<String> mRenderStrings = new ArrayList<String>(); - - private class TileDrawable extends ShapeDrawable { - TileData tile; - String label; - - public TileDrawable(TileData t, int colorId) { - this.tile = t; - getPaint().setColor(getResources().getColor(colorId)); - if (colorId == R.color.ready_tile - || colorId == R.color.unready_tile) { - - label = (int) (t.left / TILE_SCALE) + ", " - + (int) (t.top / TILE_SCALE); - // ignore scale value for tiles - setBounds(t.left, t.top, - t.right, t.bottom); - } else { - setBounds((int) (t.left * t.scale), - (int) (t.top * t.scale), - (int) (t.right * t.scale), - (int) (t.bottom * t.scale)); - } - } - - @SuppressWarnings("unused") - public void setColor(int color) { - getPaint().setColor(color); - } - - @Override - public void draw(Canvas canvas) { - super.draw(canvas); - if (label != null) { - canvas.drawText(Integer.toString(tile.level), getBounds().left, - getBounds().bottom, levelPaint); - canvas.drawText(label, getBounds().left, - ((getBounds().bottom + getBounds().top) / 2), - coordPaint); - } - } - } - - public PlaybackView(Context context) { - super(context); - init(); - } - - public PlaybackView(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - } - - public PlaybackView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - init(); - } - - public void setOnGestureListener(OnGestureListener gl) { - mGestureDetector = new GestureDetector(getContext(), gl); - } - - @Override - public boolean onTouchEvent(MotionEvent event) { - mGestureDetector.onTouchEvent(event); - return true; - } - - private void init() { - levelPaint = new Paint(); - levelPaint.setColor(Color.WHITE); - levelPaint.setTextSize(TILE_SCALE / 2); - coordPaint = new Paint(); - coordPaint.setColor(Color.BLACK); - coordPaint.setTextSize(TILE_SCALE / 3); - goldPaint = new Paint(); - goldPaint.setColor(0xffa0e010); - mGraphs = new PlaybackGraphs(); - } - - @Override - protected void onDraw(Canvas canvas) { - super.onDraw(canvas); - - if (mTempShapes == null || mTempShapes.isEmpty()) { - return; - } - - mGraphs.draw(canvas, mTempShapes, mRenderStrings, getResources()); - invalidate(); // may have animations, force redraw - } - - private String statString(int labelId, int value) { - return getResources().getString(R.string.format_stat_name, - getResources().getString(labelId), value); - } - private String tileString(int formatStringId, TileData t) { - return getResources().getString(formatStringId, - t.left, t.top, t.right, t.bottom); - } - - public int setFrame(int frame) { - if (mProfData == null || mProfData.frames.length == 0) { - return 0; - } - - int readyTiles = 0, unreadyTiles = 0, unplacedTiles = 0, numInvals = 0; - mTempShapes.clear(); - mRenderStrings.clear(); - - // create tile shapes (as they're drawn on bottom) - for (TileData t : mProfData.frames[frame]) { - if (t == mProfData.frames[frame][0]){ - // viewport 'tile', add coords to render strings - mRenderStrings.add(tileString(R.string.format_view_pos, t)); - } else if (t.level != INVAL_FLAG) { - int colorId; - if (t.isReady) { - readyTiles++; - colorId = R.color.ready_tile; - } else { - unreadyTiles++; - colorId = R.color.unready_tile; - } - if (t.left < 0 || t.top < 0) { - unplacedTiles++; - } - mTempShapes.add(new TileDrawable(t, colorId)); - } else { - // inval 'tile', count and add coords to render strings - numInvals++; - mRenderStrings.add(tileString(R.string.format_inval_pos, t)); - } - } - - // create invalidate shapes (drawn above tiles) - int invalId = 0; - for (TileData t : mProfData.frames[frame]) { - if (t.level == INVAL_FLAG && t != mProfData.frames[frame][0]) { - TileDrawable invalShape = new TileDrawable(t, - R.color.inval_region_start); - ValueAnimator tileAnimator = ObjectAnimator.ofInt(invalShape, - "color", - getResources().getColor(R.color.inval_region_start), - getResources().getColor(R.color.inval_region_stop)); - tileAnimator.setDuration(numInvals * INVAL_CYCLE); - tileAnimator.setEvaluator(new ArgbEvaluator()); - tileAnimator.setRepeatCount(ValueAnimator.INFINITE); - tileAnimator.setRepeatMode(ValueAnimator.RESTART); - float delay = (float) (invalId) * INVAL_CYCLE; - tileAnimator.setStartDelay((int) delay); - invalId++; - tileAnimator.start(); - - mTempShapes.add(invalShape); - } - } - - mRenderStrings.add(statString(R.string.ready_tiles, readyTiles)); - mRenderStrings.add(statString(R.string.unready_tiles, unreadyTiles)); - mRenderStrings.add(statString(R.string.unplaced_tiles, unplacedTiles)); - mRenderStrings.add(statString(R.string.number_invalidates, numInvals)); - - // draw view rect (using first TileData object, on top) - TileDrawable viewShape = new TileDrawable(mProfData.frames[frame][0], - R.color.view); - mTempShapes.add(viewShape); - this.invalidate(); - return frame; - } - - public void setData(RunData tileProfilingData) { - mProfData = tileProfilingData; - - mGraphs.setData(mProfData); - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java deleted file mode 100644 index 2e77157..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfileActivity.java +++ /dev/null @@ -1,337 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import android.app.Activity; -import android.content.Intent; -import android.content.Context; -import android.graphics.Bitmap; -import android.os.AsyncTask; -import android.os.Bundle; -import android.os.CountDownTimer; -import android.util.Log; -import android.util.Pair; -import android.view.KeyEvent; -import android.view.View; -import android.view.View.OnClickListener; -import android.webkit.WebView; -import android.webkit.WebViewClient; -import android.widget.AdapterView; -import android.widget.AdapterView.OnItemSelectedListener; -import android.widget.ArrayAdapter; -import android.widget.Button; -import android.widget.EditText; -import android.widget.Spinner; -import android.widget.TextView; -import android.widget.TextView.OnEditorActionListener; -import android.widget.ToggleButton; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.ObjectOutputStream; - -/** - * Interface for profiling the webview's scrolling, with simple controls on how - * to scroll, and what content to load. - */ -public class ProfileActivity extends Activity { - - private static final int TIMED_RECORD_MILLIS = 2000; - - public interface ProfileCallback { - public void profileCallback(RunData data); - } - - public static final String TEMP_FILENAME = "profile.tiles"; - - Button mInspectButton; - ToggleButton mCaptureButton; - Spinner mVelocitySpinner; - Spinner mMovementSpinner; - EditText mUrl; - ProfiledWebView mWeb; - ProfileCallback mCallback; - - LoggingWebViewClient mLoggingWebViewClient = new LoggingWebViewClient(); - AutoLoggingWebViewClient mAutoLoggingWebViewClient = new AutoLoggingWebViewClient(); - TimedLoggingWebViewClient mTimedLoggingWebViewClient = new TimedLoggingWebViewClient(); - - private enum TestingState { - NOT_TESTING, - PRE_TESTING, - START_TESTING, - STOP_TESTING, - SAVED_TESTING - }; - - private class VelocitySelectedListener implements OnItemSelectedListener { - @Override - public void onItemSelected(AdapterView<?> parent, View view, - int position, long id) { - String speedStr = parent.getItemAtPosition(position).toString(); - int speedInt = Integer.parseInt(speedStr); - mWeb.setAutoScrollSpeed(speedInt); - } - - @Override - public void onNothingSelected(AdapterView<?> parent) { - } - } - - private class MovementSelectedListener implements OnItemSelectedListener { - @Override - public void onItemSelected(AdapterView<?> parent, View view, - int position, long id) { - String movementStr = parent.getItemAtPosition(position).toString(); - if (movementStr == getResources().getString(R.string.movement_auto_scroll)) { - mWeb.setWebViewClient(mAutoLoggingWebViewClient); - mCaptureButton.setEnabled(false); - mVelocitySpinner.setEnabled(true); - } else if (movementStr == getResources().getString(R.string.movement_manual)) { - mWeb.setWebViewClient(mLoggingWebViewClient); - mCaptureButton.setEnabled(true); - mVelocitySpinner.setEnabled(false); - } else if (movementStr == getResources().getString(R.string.movement_timed)) { - mWeb.setWebViewClient(mTimedLoggingWebViewClient); - mCaptureButton.setEnabled(false); - mVelocitySpinner.setEnabled(false); - } - } - - @Override - public void onNothingSelected(AdapterView<?> parent) { - } - } - - private class LoggingWebViewClient extends WebViewClient { - @Override - public boolean shouldOverrideUrlLoading(WebView view, String url) { - return false; - } - - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - mUrl.setText(url); - } - - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - view.requestFocus(); - ((ProfiledWebView)view).onPageFinished(); - } - } - - private class AutoLoggingWebViewClient extends LoggingWebViewClient { - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - startViewProfiling(true); - } - - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - setTestingState(TestingState.PRE_TESTING); - } - } - - private class TimedLoggingWebViewClient extends LoggingWebViewClient { - @Override - public void onPageFinished(WebView view, String url) { - super.onPageFinished(view, url); - startViewProfiling(false); - - // after a fixed time after page finished, stop testing - new CountDownTimer(TIMED_RECORD_MILLIS, TIMED_RECORD_MILLIS) { - @Override - public void onTick(long millisUntilFinished) { - } - - @Override - public void onFinish() { - mWeb.stopScrollTest(); - } - }.start(); - } - - @Override - public void onPageStarted(WebView view, String url, Bitmap favicon) { - super.onPageStarted(view, url, favicon); - setTestingState(TestingState.PRE_TESTING); - } - } - - private class StoreFileTask extends - AsyncTask<Pair<String, RunData>, Void, Void> { - - @Override - protected Void doInBackground(Pair<String, RunData>... params) { - try { - FileOutputStream fos = openFileOutput(params[0].first, - Context.MODE_PRIVATE); - ObjectOutputStream out = new ObjectOutputStream(fos); - out.writeObject(params[0].second); - out.close(); - } catch (IOException ex) { - ex.printStackTrace(); - } - return null; - } - - @Override - protected void onPostExecute(Void v) { - setTestingState(TestingState.SAVED_TESTING); - } - } - - public void setTestingState(TestingState state) { - switch (state) { - case NOT_TESTING: - mUrl.setBackgroundResource(R.color.background_not_testing); - mInspectButton.setEnabled(true); - mMovementSpinner.setEnabled(true); - break; - case PRE_TESTING: - mInspectButton.setEnabled(false); - mMovementSpinner.setEnabled(false); - break; - case START_TESTING: - mCaptureButton.setChecked(true); - mUrl.setBackgroundResource(R.color.background_start_testing); - mInspectButton.setEnabled(false); - mMovementSpinner.setEnabled(false); - break; - case STOP_TESTING: - mCaptureButton.setChecked(false); - mUrl.setBackgroundResource(R.color.background_stop_testing); - break; - case SAVED_TESTING: - mInspectButton.setEnabled(true); - mMovementSpinner.setEnabled(true); - break; - } - } - - /** auto - automatically scroll. */ - private void startViewProfiling(boolean auto) { - // toggle capture button to indicate capture state to user - mWeb.startScrollTest(mCallback, auto); - setTestingState(TestingState.START_TESTING); - } - - /** Called when the activity is first created. */ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.main); - mInspectButton = (Button) findViewById(R.id.inspect); - mCaptureButton = (ToggleButton) findViewById(R.id.capture); - mVelocitySpinner = (Spinner) findViewById(R.id.velocity); - mMovementSpinner = (Spinner) findViewById(R.id.movement); - mUrl = (EditText) findViewById(R.id.url); - mWeb = (ProfiledWebView) findViewById(R.id.web); - setCallback(new ProfileCallback() { - @SuppressWarnings("unchecked") - @Override - public void profileCallback(RunData data) { - new StoreFileTask().execute(new Pair<String, RunData>( - TEMP_FILENAME, data)); - Log.d("ProfileActivity", "stored " + data.frames.length + " frames in file"); - setTestingState(TestingState.STOP_TESTING); - } - }); - - // Inspect button (opens PlaybackActivity) - mInspectButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - startActivity(new Intent(ProfileActivity.this, - PlaybackActivity.class)); - } - }); - - // Velocity spinner - ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource( - this, R.array.velocity_array, - android.R.layout.simple_spinner_item); - adapter.setDropDownViewResource( - android.R.layout.simple_spinner_dropdown_item); - mVelocitySpinner.setAdapter(adapter); - mVelocitySpinner.setOnItemSelectedListener( - new VelocitySelectedListener()); - mVelocitySpinner.setSelection(3); - - // Movement spinner - String content[] = { - getResources().getString(R.string.movement_auto_scroll), - getResources().getString(R.string.movement_manual), - getResources().getString(R.string.movement_timed) - }; - adapter = new ArrayAdapter<CharSequence>(this, - android.R.layout.simple_spinner_item, content); - adapter.setDropDownViewResource( - android.R.layout.simple_spinner_dropdown_item); - mMovementSpinner.setAdapter(adapter); - mMovementSpinner.setOnItemSelectedListener( - new MovementSelectedListener()); - mMovementSpinner.setSelection(0); - - // Capture toggle button - mCaptureButton.setOnClickListener(new OnClickListener() { - @Override - public void onClick(View v) { - if (mCaptureButton.isChecked()) { - startViewProfiling(false); - } else { - mWeb.stopScrollTest(); - } - } - }); - - // Custom profiling WebView - mWeb.init(this); - mWeb.setWebViewClient(new LoggingWebViewClient()); - - // URL text entry - mUrl.setOnEditorActionListener(new OnEditorActionListener() { - public boolean onEditorAction(TextView v, int actionId, - KeyEvent event) { - String url = mUrl.getText().toString(); - mWeb.loadUrl(url); - mWeb.requestFocus(); - return true; - } - }); - - setTestingState(TestingState.NOT_TESTING); - } - - public void setCallback(ProfileCallback callback) { - mCallback = callback; - } - - @Override - public boolean onKeyDown(int keyCode, KeyEvent event) { - if ((keyCode == KeyEvent.KEYCODE_BACK) && mWeb.canGoBack()) { - mWeb.goBack(); - return true; - } - return super.onKeyDown(keyCode, event); - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java b/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java deleted file mode 100644 index d3b572c..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/ProfiledWebView.java +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import android.content.Context; -import android.os.CountDownTimer; -import android.util.AttributeSet; -import android.util.Log; -import android.webkit.WebSettingsClassic; -import android.webkit.WebView; -import android.webkit.WebViewClassic; - -import java.util.ArrayList; - -import com.test.tilebenchmark.ProfileActivity.ProfileCallback; -import com.test.tilebenchmark.RunData.TileData; - -public class ProfiledWebView extends WebView implements WebViewClassic.PageSwapDelegate { - private static final String LOGTAG = "ProfiledWebView"; - - private int mSpeed; - - private boolean mIsTesting = false; - private boolean mIsScrolling = false; - private ProfileCallback mCallback; - private long mContentInvalMillis; - private static final int LOAD_STALL_MILLIS = 2000; // nr of millis after load, - // before test is forced - - // ignore anim end events until this many millis after load - private static final long ANIM_SAFETY_THRESHOLD = 200; - private long mLoadTime; - private long mAnimationTime; - - public ProfiledWebView(Context context) { - super(context); - } - - public ProfiledWebView(Context context, AttributeSet attrs) { - super(context, attrs); - } - - public ProfiledWebView(Context context, AttributeSet attrs, int defStyle) { - super(context, attrs, defStyle); - } - - public ProfiledWebView(Context context, AttributeSet attrs, int defStyle, - boolean privateBrowsing) { - super(context, attrs, defStyle, privateBrowsing); - } - - private class JavaScriptInterface { - Context mContext; - - /** Instantiate the interface and set the context */ - JavaScriptInterface(Context c) { - mContext = c; - } - - public void animationComplete() { - mAnimationTime = System.currentTimeMillis(); - } - } - - public void init(Context c) { - WebSettingsClassic settings = getWebViewClassic().getSettings(); - settings.setJavaScriptEnabled(true); - settings.setSupportZoom(true); - settings.setEnableSmoothTransition(true); - settings.setBuiltInZoomControls(true); - settings.setLoadWithOverviewMode(true); - settings.setProperty("use_minimal_memory", "false"); // prefetch tiles, as browser does - addJavascriptInterface(new JavaScriptInterface(c), "Android"); - mAnimationTime = 0; - mLoadTime = 0; - } - - public void setUseMinimalMemory(boolean minimal) { - WebSettingsClassic settings = getWebViewClassic().getSettings(); - settings.setProperty("use_minimal_memory", minimal ? "true" : "false"); - } - - public void onPageFinished() { - mLoadTime = System.currentTimeMillis(); - } - - @Override - protected void onDraw(android.graphics.Canvas canvas) { - if (mIsTesting && mIsScrolling) { - if (canScrollVertically(1)) { - scrollBy(0, mSpeed); - } else { - stopScrollTest(); - mIsScrolling = false; - } - } - super.onDraw(canvas); - } - - /* - * Called once the page is loaded to start scrolling for evaluating tiles. - * If autoScrolling isn't set, stop must be called manually. Before - * scrolling, invalidate all content and redraw it, measuring time taken. - */ - public void startScrollTest(ProfileCallback callback, boolean autoScrolling) { - mCallback = callback; - mIsTesting = false; - mIsScrolling = false; - WebSettingsClassic settings = getWebViewClassic().getSettings(); - settings.setProperty("tree_updates", "0"); - - - 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() { - // invalidate all content, and kick off redraw - Log.d("ProfiledWebView", - "kicking off test with callback registration, and tile discard..."); - getWebViewClassic().discardAllTextures(); - invalidate(); - mIsScrolling = true; - mContentInvalMillis = System.currentTimeMillis(); - } - }.start(); - } else { - mIsTesting = true; - getWebViewClassic().tileProfilingStart(); - } - } - - /* - * Called after the manual contentInvalidateAll, after the tiles have all - * been redrawn. - * From PageSwapDelegate. - */ - @Override - public void onPageSwapOccurred(boolean startAnim) { - if (!mIsTesting && mIsScrolling) { - // kick off testing - mContentInvalMillis = System.currentTimeMillis() - mContentInvalMillis; - Log.d("ProfiledWebView", "REDRAW TOOK " + mContentInvalMillis + "millis"); - mIsTesting = true; - invalidate(); // ensure a redraw so that auto-scrolling can occur - getWebViewClassic().tileProfilingStart(); - } - } - - private double animFramerate() { - WebSettingsClassic settings = getWebViewClassic().getSettings(); - String updatesString = settings.getProperty("tree_updates"); - int updates = (updatesString == null) ? -1 : Integer.parseInt(updatesString); - - long animationTime; - if (mAnimationTime == 0 || mAnimationTime - mLoadTime < ANIM_SAFETY_THRESHOLD) { - animationTime = System.currentTimeMillis() - mLoadTime; - } else { - animationTime = mAnimationTime - mLoadTime; - } - - return updates * 1000.0 / animationTime; - } - - public void setDoubleBuffering(boolean useDoubleBuffering) { - WebSettingsClassic settings = getWebViewClassic().getSettings(); - settings.setProperty("use_double_buffering", useDoubleBuffering ? "true" : "false"); - } - - /* - * Called once the page has stopped scrolling - */ - public void stopScrollTest() { - getWebViewClassic().tileProfilingStop(); - mIsTesting = false; - - if (mCallback == null) { - getWebViewClassic().tileProfilingClear(); - return; - } - - RunData data = new RunData(getWebViewClassic().tileProfilingNumFrames()); - // record the time spent (before scrolling) rendering the page - data.singleStats.put(getResources().getString(R.string.render_millis), - (double)mContentInvalMillis); - - // record framerate - double framerate = animFramerate(); - Log.d(LOGTAG, "anim framerate was "+framerate); - data.singleStats.put(getResources().getString(R.string.animation_framerate), - framerate); - - for (int frame = 0; frame < data.frames.length; frame++) { - data.frames[frame] = new TileData[ - getWebViewClassic().tileProfilingNumTilesInFrame(frame)]; - for (int tile = 0; tile < data.frames[frame].length; tile++) { - int left = getWebViewClassic().tileProfilingGetInt(frame, tile, "left"); - int top = getWebViewClassic().tileProfilingGetInt(frame, tile, "top"); - int right = getWebViewClassic().tileProfilingGetInt(frame, tile, "right"); - int bottom = getWebViewClassic().tileProfilingGetInt(frame, tile, "bottom"); - - boolean isReady = getWebViewClassic().tileProfilingGetInt( - frame, tile, "isReady") == 1; - int level = getWebViewClassic().tileProfilingGetInt(frame, tile, "level"); - - float scale = getWebViewClassic().tileProfilingGetFloat(frame, tile, "scale"); - - data.frames[frame][tile] = data.new TileData(left, top, right, bottom, - isReady, level, scale); - } - } - getWebViewClassic().tileProfilingClear(); - - mCallback.profileCallback(data); - } - - @Override - public void loadUrl(String url) { - mAnimationTime = 0; - mLoadTime = 0; - if (!url.startsWith("http://") && !url.startsWith("file://")) { - url = "http://" + url; - } - super.loadUrl(url); - } - - public void setAutoScrollSpeed(int speedInt) { - mSpeed = speedInt; - } - - public WebViewClassic getWebViewClassic() { - return WebViewClassic.fromWebView(this); - } -} diff --git a/tests/TileBenchmark/src/com/test/tilebenchmark/RunData.java b/tests/TileBenchmark/src/com/test/tilebenchmark/RunData.java deleted file mode 100644 index 5e48afd..0000000 --- a/tests/TileBenchmark/src/com/test/tilebenchmark/RunData.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (C) 2011 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.test.tilebenchmark; - -import java.io.Serializable; -import java.util.HashMap; - -public class RunData implements Serializable { - public TileData[][] frames; - public HashMap<String, Double> singleStats = new HashMap<String, Double>(); - - public RunData(int frames) { - this.frames = new TileData[frames][]; - } - - public class TileData implements Serializable { - public int left, top, right, bottom; - public boolean isReady; - public int level; - public float scale; - - public TileData(int left, int top, int right, int bottom, - boolean isReady, int level, float scale) { - this.left = left; - this.right = right; - this.top = top; - this.bottom = bottom; - this.isReady = isReady; - this.level = level; - this.scale = scale; - } - - public String toString() { - return "Tile (" + left + "," + top + ")->(" - + right + "," + bottom + ")" - + (isReady ? "ready" : "NOTready") + " at scale " + scale; - } - } - -} |