diff options
author | John Reck <jreck@google.com> | 2016-11-15 09:24:36 -0800 |
---|---|---|
committer | John Reck <jreck@google.com> | 2016-11-17 09:03:31 -0800 |
commit | 24e98b7667da2ba7718e111c4b6d5d739e67e4f4 (patch) | |
tree | b3334d24ac77c64fad251dac52b022a8058a40da | |
parent | ceb9ec6dbfb5bd26aad1280e9aeb28ca17b8fcf8 (diff) |
Add more complex View inflation bench
Test: ran ViewPerfTest#testTwelveKeyInflate
Change-Id: I644e1f77fa1108dcd2d54216d1e740b112a2e21b
3 files changed, 194 insertions, 1 deletions
diff --git a/apct-tests/perftests/core/res/layout/twelve_key_entry.xml b/apct-tests/perftests/core/res/layout/twelve_key_entry.xml new file mode 100644 index 000000000000..4d68018d19e3 --- /dev/null +++ b/apct-tests/perftests/core/res/layout/twelve_key_entry.xml @@ -0,0 +1,182 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- +/* +** Copyright 2016, 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. +*/ +--> + +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" + android:orientation="vertical" + android:layout_width="match_parent" + android:layout_height="match_parent"> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="64dip" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:orientation="horizontal"> + + <Button android:id="@+id/one" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/two" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/three" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="64dip" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:orientation="horizontal"> + + <Button android:id="@+id/four" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/five" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/six" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="64dip" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:orientation="horizontal"> + + <Button android:id="@+id/seven" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/eight" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/nine" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + </LinearLayout> + + <LinearLayout + android:layout_width="fill_parent" + android:layout_height="64dip" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:orientation="horizontal"> + + <Button android:id="@+id/cancel" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textStyle="bold" + android:text="@android:string/cancel" + /> + + <Button android:id="@+id/zero" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceLarge" + android:textStyle="bold" + /> + + <Button android:id="@+id/ok" + android:layout_width="0sp" + android:layout_height="fill_parent" + android:layout_weight="1" + android:layout_marginStart="2dip" + android:layout_marginEnd="2dip" + android:textAppearance="?android:attr/textAppearanceMedium" + android:textStyle="bold" + android:text="@android:string/ok" + /> + + </LinearLayout> + +</LinearLayout> diff --git a/apct-tests/perftests/core/src/android/view/ViewPerfTest.java b/apct-tests/perftests/core/src/android/view/ViewPerfTest.java index 5503ca94134e..990be24bc805 100644 --- a/apct-tests/perftests/core/src/android/view/ViewPerfTest.java +++ b/apct-tests/perftests/core/src/android/view/ViewPerfTest.java @@ -44,4 +44,15 @@ public class ViewPerfTest { inflater.inflate(R.layout.test_simple_view, root, false); } } + + @Test + public void testTwelveKeyInflate() { + final BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); + final Context context = InstrumentationRegistry.getInstrumentation().getTargetContext(); + LayoutInflater inflater = LayoutInflater.from(context); + FrameLayout root = new FrameLayout(context); + while (state.keepRunning()) { + inflater.inflate(R.layout.twelve_key_entry, root, false); + } + } } diff --git a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java index fd393e9d070c..bb9dc4ae562e 100644 --- a/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java +++ b/apct-tests/perftests/utils/src/android/perftests/utils/BenchmarkState.java @@ -63,7 +63,7 @@ public final class BenchmarkState { // TODO: Tune these values. private static final long TARGET_TEST_DURATION_NS = ms2ns(500); // target testing for 500 ms private static final int MAX_TEST_ITERATIONS = 1000000; - private static final int MIN_TEST_ITERATIONS = 100; + private static final int MIN_TEST_ITERATIONS = 10; private static final int REPEAT_COUNT = 5; private long mStartTimeNs = 0; // Previously captured System.nanoTime(). |