Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 24e98b76 authored by John Reck's avatar John Reck
Browse files

Add more complex View inflation bench

Test: ran ViewPerfTest#testTwelveKeyInflate

Change-Id: I644e1f77fa1108dcd2d54216d1e740b112a2e21b
parent ceb9ec6d
Loading
Loading
Loading
Loading
+182 −0
Original line number Diff line number Diff line
<?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>
+11 −0
Original line number Diff line number Diff line
@@ -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);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -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().