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

Commit f0b0a10d authored by Seigo Nonaka's avatar Seigo Nonaka Committed by Android (Google) Code Review
Browse files

Merge "Revert "Reorganize MeasuredText API""

parents c0451c36 4e90fa26
Loading
Loading
Loading
Loading
+22 −34
Original line number Diff line number Diff line
@@ -45,7 +45,7 @@ import java.util.Random;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class PrecomputedTextMemoryUsageTest {
public class MeasuredTextMemoryUsageTest {
    private static final int WORD_LENGTH = 9;  // Random word has 9 characters.
    private static final boolean NO_STYLE_TEXT = false;

@@ -53,7 +53,7 @@ public class PrecomputedTextMemoryUsageTest {

    private static int TRIAL_COUNT = 100;

    public PrecomputedTextMemoryUsageTest() {}
    public MeasuredTextMemoryUsageTest() {}

    private TextPerfUtils mTextUtil = new TextPerfUtils();

@@ -77,16 +77,13 @@ public class PrecomputedTextMemoryUsageTest {
    @Test
    public void testMemoryUsage_NoHyphenation() {
        int[] memories = new int[TRIAL_COUNT];
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
        // Report median of randomly generated MeasuredText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        // Report median of randomly generated PrecomputedText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = PrecomputedText.create(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), param)
                .getMemoryUsage();
                .build().getMemoryUsage();
        }
        reportMemoryUsage(median(memories), "MemoryUsage_NoHyphenation");
    }
@@ -94,16 +91,13 @@ public class PrecomputedTextMemoryUsageTest {
    @Test
    public void testMemoryUsage_Hyphenation() {
        int[] memories = new int[TRIAL_COUNT];
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
        // Report median of randomly generated MeasuredText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        // Report median of randomly generated PrecomputedText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = PrecomputedText.create(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), param)
                .getMemoryUsage();
                .build().getMemoryUsage();
        }
        reportMemoryUsage(median(memories), "MemoryUsage_Hyphenation");
    }
@@ -111,16 +105,13 @@ public class PrecomputedTextMemoryUsageTest {
    @Test
    public void testMemoryUsage_NoHyphenation_WidthOnly() {
        int[] memories = new int[TRIAL_COUNT];
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
        // Report median of randomly generated MeasuredText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        // Report median of randomly generated PrecomputedText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            CharSequence cs = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            memories[i] = PrecomputedText.createWidthOnly(cs, param, 0, cs.length())
                .getMemoryUsage();
                .build(false /* width only */).getMemoryUsage();
        }
        reportMemoryUsage(median(memories), "MemoryUsage_NoHyphenation_WidthOnly");
    }
@@ -128,16 +119,13 @@ public class PrecomputedTextMemoryUsageTest {
    @Test
    public void testMemoryUsage_Hyphenatation_WidthOnly() {
        int[] memories = new int[TRIAL_COUNT];
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
        // Report median of randomly generated MeasuredText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            memories[i] = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        // Report median of randomly generated PrecomputedText.
        for (int i = 0; i < TRIAL_COUNT; ++i) {
            CharSequence cs = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            memories[i] = PrecomputedText.createWidthOnly(cs, param, 0, cs.length())
                .getMemoryUsage();
                .build(false /* width only */).getMemoryUsage();
        }
        reportMemoryUsage(median(memories), "MemoryUsage_Hyphenation_WidthOnly");
    }
+34 −50
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ import java.util.Random;

@LargeTest
@RunWith(AndroidJUnit4.class)
public class PrecomputedTextPerfTest {
public class MeasuredTextPerfTest {
    private static final int WORD_LENGTH = 9;  // Random word has 9 characters.
    private static final int WORDS_IN_LINE = 8;  // Roughly, 8 words in a line.
    private static final boolean NO_STYLE_TEXT = false;
@@ -51,7 +51,7 @@ public class PrecomputedTextPerfTest {
    private static TextPaint PAINT = new TextPaint();
    private static final int TEXT_WIDTH = WORDS_IN_LINE * WORD_LENGTH * (int) PAINT.getTextSize();

    public PrecomputedTextPerfTest() {}
    public MeasuredTextPerfTest() {}

    @Rule
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
@@ -66,136 +66,120 @@ public class PrecomputedTextPerfTest {
    @Test
    public void testCreate_NoStyled_Hyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build(true /* do full layout */);
        }
    }

    @Test
    public void testCreate_NoStyled_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build(true /* do full layout */);
        }
    }

    @Test
    public void testCreate_NoStyled_Hyphenation_WidthOnly() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build(false /* width only */);
        }
    }

    @Test
    public void testCreate_NoStyled_NoHyphenation_WidthOnly() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build(false /* width only */);
        }
    }

    @Test
    public void testCreate_Styled_Hyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build(true /* do full layout */);
        }
    }

    @Test
    public void testCreate_Styled_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build(true /* do full layout */);
        }
    }

    @Test
    public void testCreate_Styled_Hyphenation_WidthOnly() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build(false /* width only */);
        }
    }

    @Test
    public void testCreate_Styled_NoHyphenation_WidthOnly() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final PrecomputedText.Params param = new PrecomputedText.Params.Builder(PAINT)
                .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                .build();

        while (state.keepRunning()) {
            state.pauseTiming();
            final CharSequence text = mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT);
            state.resumeTiming();

            PrecomputedText.create(text, param);
            new MeasuredText.Builder(text, PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build(false /* width only */);
        }
    }
}
+51 −57
Original line number Diff line number Diff line
@@ -63,18 +63,6 @@ public class StaticLayoutPerfTest {
        mTextUtil.resetRandom(0 /* seed */);
    }

    private PrecomputedText makeMeasured(CharSequence text, TextPaint paint) {
        PrecomputedText.Params param = new PrecomputedText.Params.Builder(paint).build();
        return PrecomputedText.create(text, param);
    }

    private PrecomputedText makeMeasured(CharSequence text, TextPaint paint, int strategy,
                                      int frequency) {
        PrecomputedText.Params param = new PrecomputedText.Params.Builder(paint)
                .setHyphenationFrequency(frequency).setBreakStrategy(strategy).build();
        return PrecomputedText.create(text, param);
    }

    @Test
    public void testCreate_FixedText_NoStyle_Greedy_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
@@ -163,16 +151,18 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testCreate_PrecomputedText_NoStyled_Greedy_NoHyphenation() {
    public void testCreate_MeasuredText_NoStyled_Greedy_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT,
                    Layout.BREAK_STRATEGY_SIMPLE, Layout.HYPHENATION_FREQUENCY_NONE);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build();
            state.resumeTiming();

            StaticLayout.Builder.obtain(text, 0, text.getText().length(), PAINT, TEXT_WIDTH)
            StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .build();
@@ -180,16 +170,18 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testCreate_PrecomputedText_NoStyled_Greedy_Hyphenation() {
    public void testCreate_MeasuredText_NoStyled_Greedy_Hyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT,
                    Layout.BREAK_STRATEGY_SIMPLE, Layout.HYPHENATION_FREQUENCY_NORMAL);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build();
            state.resumeTiming();

            StaticLayout.Builder.obtain(text, 0, text.getText().length(), PAINT, TEXT_WIDTH)
            StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .build();
@@ -197,16 +189,18 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testCreate_PrecomputedText_NoStyled_Balanced_NoHyphenation() {
    public void testCreate_MeasuredText_NoStyled_Balanced_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT,
                    Layout.BREAK_STRATEGY_BALANCED, Layout.HYPHENATION_FREQUENCY_NONE);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build();
            state.resumeTiming();

            StaticLayout.Builder.obtain(text, 0, text.getText().length(), PAINT, TEXT_WIDTH)
            StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .build();
@@ -214,16 +208,18 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testCreate_PrecomputedText_NoStyled_Balanced_Hyphenation() {
    public void testCreate_MeasuredText_NoStyled_Balanced_Hyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT,
                    Layout.BREAK_STRATEGY_BALANCED, Layout.HYPHENATION_FREQUENCY_NORMAL);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .build();
            state.resumeTiming();

            StaticLayout.Builder.obtain(text, 0, text.getText().length(), PAINT, TEXT_WIDTH)
            StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_BALANCED)
                    .build();
@@ -231,16 +227,18 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testCreate_PrecomputedText_Styled_Greedy_NoHyphenation() {
    public void testCreate_MeasuredText_Styled_Greedy_NoHyphenation() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT,
                    Layout.BREAK_STRATEGY_SIMPLE, Layout.HYPHENATION_FREQUENCY_NONE);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .build();
            state.resumeTiming();

            StaticLayout.Builder.obtain(text, 0, text.getText().length(), PAINT, TEXT_WIDTH)
            StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH)
                    .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NONE)
                    .setBreakStrategy(Layout.BREAK_STRATEGY_SIMPLE)
                    .build();
@@ -330,16 +328,15 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testDraw_PrecomputedText_Styled() {
    public void testDraw_MeasuredText_Styled() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final RenderNode node = RenderNode.create("benchmark", null);
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT).build();
            final StaticLayout layout =
                    StaticLayout.Builder.obtain(
                            text, 0, text.getText().length(), PAINT, TEXT_WIDTH).build();
                    StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH).build();
            final DisplayListCanvas c = node.start(1200, 200);
            state.resumeTiming();

@@ -348,16 +345,15 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testDraw_PrecomputedText_NoStyled() {
    public void testDraw_MeasuredText_NoStyled() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final RenderNode node = RenderNode.create("benchmark", null);
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT).build();
            final StaticLayout layout =
                    StaticLayout.Builder.obtain(
                            text, 0, text.getText().length(), PAINT, TEXT_WIDTH).build();
                    StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH).build();
            final DisplayListCanvas c = node.start(1200, 200);
            state.resumeTiming();

@@ -366,16 +362,15 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testDraw_PrecomputedText_Styled_WithoutCache() {
    public void testDraw_MeasuredText_Styled_WithoutCache() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final RenderNode node = RenderNode.create("benchmark", null);
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, STYLE_TEXT), PAINT).build();
            final StaticLayout layout =
                    StaticLayout.Builder.obtain(
                            text, 0, text.getText().length(), PAINT, TEXT_WIDTH).build();
                    StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH).build();
            final DisplayListCanvas c = node.start(1200, 200);
            Canvas.freeTextLayoutCaches();
            state.resumeTiming();
@@ -385,16 +380,15 @@ public class StaticLayoutPerfTest {
    }

    @Test
    public void testDraw_PrecomputedText_NoStyled_WithoutCache() {
    public void testDraw_MeasuredText_NoStyled_WithoutCache() {
        final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        final RenderNode node = RenderNode.create("benchmark", null);
        while (state.keepRunning()) {
            state.pauseTiming();
            final PrecomputedText text = makeMeasured(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT);
            final MeasuredText text = new MeasuredText.Builder(
                    mTextUtil.nextRandomParagraph(WORD_LENGTH, NO_STYLE_TEXT), PAINT).build();
            final StaticLayout layout =
                    StaticLayout.Builder.obtain(
                            text, 0, text.getText().length(), PAINT, TEXT_WIDTH).build();
                    StaticLayout.Builder.obtain(text, 0, text.length(), PAINT, TEXT_WIDTH).build();
            final DisplayListCanvas c = node.start(1200, 200);
            Canvas.freeTextLayoutCaches();
            state.resumeTiming();
+30 −31

File changed.

Preview size limit exceeded, changes collapsed.

+7 −12

File changed.

Preview size limit exceeded, changes collapsed.

Loading