Add perf test for Typeface with variation axes.
std::unordered_set<AxisTag> consumes considerable memory in minikin, as it requires at least 40 bytes (on aarch64) per instance. We'd like to optimize it. This CL adds perf test to make sure that the latency does not regress by the memory optimization. Bug: 174672300 Test: atest CorePerfTests:android.graphics.perftests.TypefaceCreatePerfTest Change-Id: I5585d058db6195efc05e0f0be3de49b32818414a
This commit is contained in:
@@ -16,10 +16,13 @@
|
||||
|
||||
package android.graphics.perftests;
|
||||
|
||||
import static org.junit.Assume.assumeNotNull;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.fonts.FontVariationAxis;
|
||||
import android.perftests.utils.BenchmarkState;
|
||||
import android.perftests.utils.PerfStatusReporter;
|
||||
|
||||
@@ -39,6 +42,8 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@LargeTest
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@@ -140,4 +145,18 @@ public class TypefaceCreatePerfTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreate_fromTypefaceWithVariation() {
|
||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||
final List<FontVariationAxis> axes = Arrays.asList(
|
||||
new FontVariationAxis("wght", 100f),
|
||||
new FontVariationAxis("wdth", 0.8f));
|
||||
|
||||
while (state.keepRunning()) {
|
||||
Typeface face = Typeface.createFromTypefaceWithVariation(Typeface.SANS_SERIF, axes);
|
||||
// Make sure that the test device has variable fonts.
|
||||
assumeNotNull(face);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user