Introduce MeasuredText related perf tests
This CL adds two perf test for MeasuredText: the memory usage and
construction time of MeasuredText.
Here is an example output on walleye-userdebug:
Memory Usage (in bytes)
Hyphenation : 28,448
Hyphenation WidthOnly : 8,856
NoHyphenation : 27,592
NoHyphenation WidthOnly: 8,000
MeasuredText creation time
NoStyled Hyphenation : 18,977,877
NoStyled Hyphenation WidthOnly : 18,510,041
NoStyled NoHyphenation : 7,771,936
NoStyled NoHyphenation WidthOnly: 7,332,537
Styled Hyphenation : 13,514,428
Styled Hyphenation WidthOnly : 12,446,143
Styled NoHyphenation : 13,370,358
Styled NoHyphenation WidthOnly : 13,582,435
Bug: 72461923
Bug: 72462192
Test: See above
Change-Id: I7d326a9e70a29c38c940e0085da2bc4edf2a098a
diff --git a/core/java/android/text/MeasuredParagraph.java b/core/java/android/text/MeasuredParagraph.java
index 45fbf6f..aafcf44 100644
--- a/core/java/android/text/MeasuredParagraph.java
+++ b/core/java/android/text/MeasuredParagraph.java
@@ -672,6 +672,13 @@
return width;
}
+ /**
+ * This only works if the MeasuredParagraph is computed with buildForStaticLayout.
+ */
+ @IntRange(from = 0) int getMemoryUsage() {
+ return nGetMemoryUsage(mNativePtr);
+ }
+
private static native /* Non Zero */ long nInitBuilder();
/**
@@ -718,4 +725,7 @@
@CriticalNative
private static native /* Non Zero */ long nGetReleaseFunc();
+
+ @CriticalNative
+ private static native int nGetMemoryUsage(/* Non Zero */ long nativePtr);
}