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

Commit d0a5206d authored by Siyamed Sinir's avatar Siyamed Sinir
Browse files

Reduce Text layout performance test combinations

We have measured and identified important combinations for layout
performance tests. In order to reduce the number of tests logged, this
CL removed some of the parameterized tests configurations.

Test: bit CorePerfTests:android.text.PaintMeasureDrawPerfTest
Test: bit CorePerfTests:android.text.BoringLayoutIsBoringPerfTest
Test: bit CorePerfTests:android.text.BoringLayoutCreateDrawPerfTest
Test: bit CorePerfTests:android.text.StaticLayoutCreateDrawPerfTest
Test: bit CorePerfTests:android.text.TextViewSetTextMeasurePerfTest

Bug: 67112217
Change-Id: I92a08f679a185595a519465450881a814f2b4feb
parent af479b8c
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -49,9 +49,10 @@ public class BoringLayoutCreateDrawPerfTest {
    @Parameterized.Parameters(name = "cached={3},{1} chars,{0}")
    public static Collection cases() {
        final List<Object[]> params = new ArrayList<>();
        for (int length : new int[]{32, 64, 128, 256, 512}) {
        for (int length : new int[]{128}) {
            for (boolean cached : BOOLEANS) {
                for (TextType textType : TextType.values()) {
                for (TextType textType : new TextType[]{TextType.STRING,
                        TextType.SPANNABLE_BUILDER}) {
                    params.add(new Object[]{textType.name(), length, textType, cached});
                }
            }
+3 −2
Original line number Diff line number Diff line
@@ -43,10 +43,11 @@ public class BoringLayoutIsBoringPerfTest {
    @Parameterized.Parameters(name = "cached={4},{1} chars,{0}")
    public static Collection cases() {
        final List<Object[]> params = new ArrayList<>();
        for (int length : new int[]{32, 64, 128, 256, 512}) {
        for (int length : new int[]{128}) {
            for (boolean boring : BOOLEANS) {
                for (boolean cached : BOOLEANS) {
                    for (TextType textType : TextType.values()) {
                    for (TextType textType : new TextType[]{TextType.STRING,
                            TextType.SPANNABLE_BUILDER}) {
                        params.add(new Object[]{
                                (boring ? "Boring" : "NotBoring") + "," + textType.name(),
                                length, boring, textType, cached});
+1 −1
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ public class PaintMeasureDrawPerfTest {
    @Parameterized.Parameters(name = "cached={1},{0} chars")
    public static Collection cases() {
        final List<Object[]> params = new ArrayList<>();
        for (int length : new int[]{32, 64, 128, 256, 512}) {
        for (int length : new int[]{128}) {
            for (boolean cached : BOOLEANS) {
                params.add(new Object[]{length, cached});
            }
+6 −15
Original line number Diff line number Diff line
@@ -44,8 +44,6 @@ public class StaticLayoutCreateDrawPerfTest {

    private static final boolean[] BOOLEANS = new boolean[]{false, true};

    // keep it one char longer than 32 so that 32 chars can fit into one line
    private static final int LINE_LENGTH = 33;
    private static final float SPACING_ADD = 10f;
    private static final float SPACING_MULT = 1.5f;

@@ -55,14 +53,11 @@ public class StaticLayoutCreateDrawPerfTest {
    @Parameterized.Parameters(name = "cached={3},{1} chars,{0}")
    public static Collection cases() {
        final List<Object[]> params = new ArrayList<>();
        for (int length : new int[]{32, 64, 128, 256, 512}) {
        for (int length : new int[]{128}) {
            for (boolean cached : BOOLEANS) {
                for (boolean multiLine : BOOLEANS) {
                    for (TextType textType : TextType.values()) {
                        params.add(new Object[]{
                                (multiLine ? "MultiLine" : "SingleLine") + "," + textType.name(),
                                length, textType, cached, multiLine});
                    }
                for (TextType textType : new TextType[]{TextType.STRING,
                        TextType.SPANNABLE_BUILDER}) {
                    params.add(new Object[]{textType.name(), length, textType, cached});
                }
            }
        }
@@ -73,19 +68,16 @@ public class StaticLayoutCreateDrawPerfTest {
    private final int mLength;
    private final TextType mTextType;
    private final boolean mCached;
    private final boolean mMultiLine;
    private final TextPaint mTextPaint;

    public StaticLayoutCreateDrawPerfTest(String label, int length, TextType textType,
            boolean cached, boolean multiLine) {
            boolean cached) {
        mLength = length;
        mTextType = textType;
        mCached = cached;
        mMultiLine = multiLine;
        mTextPaint = new TextPaint();
        mTextPaint.setTextSize(10);
        final CharSequence text = createRandomText(LINE_LENGTH);
        mLineWidth = mMultiLine ? (int) mTextPaint.measureText(text.toString()) : Integer.MAX_VALUE;
        mLineWidth = Integer.MAX_VALUE;
    }

    /**
@@ -120,7 +112,6 @@ public class StaticLayoutCreateDrawPerfTest {
        state.pauseTiming();
        Canvas.freeTextLayoutCaches();
        final RenderNode node = RenderNode.create("benchmark", null);
        final Random random = new Random();
        final CharSequence text = createRandomText(mLength);
        final Layout layout = createLayout(text);
        state.resumeTiming();
+6 −15
Original line number Diff line number Diff line
@@ -48,23 +48,17 @@ public class TextViewSetTextMeasurePerfTest {

    private static final boolean[] BOOLEANS = new boolean[]{false, true};

    // keep it one char longer than 32 so that 32 chars can fit into one line
    private static final int LINE_LENGTH = 33;

    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    @Parameterized.Parameters(name = "cached={3},{1} chars,{0}")
    public static Collection cases() {
        final List<Object[]> params = new ArrayList<>();
        for (int length : new int[]{32, 64, 128, 256, 512}) {
        for (int length : new int[]{128}) {
            for (boolean cached : BOOLEANS) {
                for (boolean multiLine : BOOLEANS) {
                    for (TextType textType : TextType.values()) {
                        params.add(new Object[]{
                                (multiLine ? "MultiLine" : "SingleLine") + "," + textType.name(),
                                length, textType, cached, multiLine});
                    }
                for (TextType textType : new TextType[]{TextType.STRING,
                        TextType.SPANNABLE_BUILDER}) {
                    params.add(new Object[]{textType.name(), length, textType, cached});
                }
            }
        }
@@ -75,19 +69,16 @@ public class TextViewSetTextMeasurePerfTest {
    private final int mLength;
    private final TextType mTextType;
    private final boolean mCached;
    private final boolean mMultiLine;
    private final TextPaint mTextPaint;

    public TextViewSetTextMeasurePerfTest(String label, int length, TextType textType,
            boolean cached, boolean multiLine) {
            boolean cached) {
        mLength = length;
        mTextType = textType;
        mCached = cached;
        mMultiLine = multiLine;
        mTextPaint = new TextPaint();
        mTextPaint.setTextSize(10);
        final CharSequence text = createRandomText(LINE_LENGTH);
        mLineWidth = mMultiLine ? (int) mTextPaint.measureText(text.toString()) : Integer.MAX_VALUE;
        mLineWidth = Integer.MAX_VALUE;
    }

    /**