Merge "Fix CharsetUtf8PerfTest."
This commit is contained in:
@@ -37,9 +37,7 @@ import java.nio.charset.Charset;
|
|||||||
public class CharsetUtf8PerfTest {
|
public class CharsetUtf8PerfTest {
|
||||||
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
@Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
|
||||||
|
|
||||||
private final int mNoOfBytes = 0x100; // 4MB
|
private void makeUnicodeRange(int startingCodePoint, int endingCodePoint) {
|
||||||
|
|
||||||
private void makeUnicodeRange(int startingCodePoint, int endingCodePoint, int repeated) {
|
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
for (int codePoint = startingCodePoint; codePoint <= endingCodePoint; codePoint++) {
|
for (int codePoint = startingCodePoint; codePoint <= endingCodePoint; codePoint++) {
|
||||||
if (codePoint < Character.MIN_SURROGATE || codePoint > Character.MAX_SURROGATE) {
|
if (codePoint < Character.MIN_SURROGATE || codePoint > Character.MAX_SURROGATE) {
|
||||||
@@ -48,35 +46,30 @@ public class CharsetUtf8PerfTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String str = builder.toString();
|
String str = builder.toString();
|
||||||
StringBuilder builder2 = new StringBuilder();
|
|
||||||
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
|
||||||
while (state.keepRunning()) {
|
while (state.keepRunning()) {
|
||||||
for (int i = 0; i < repeated; i++) {
|
StringBuilder builder2 = new StringBuilder();
|
||||||
builder2.append(str);
|
builder2.append(str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_ascii() {
|
public void time_ascii() {
|
||||||
makeUnicodeRange(0, 0x7f, mNoOfBytes / 0x80);
|
makeUnicodeRange(0, 0x7f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_bmp2() {
|
public void time_bmp2() {
|
||||||
makeUnicodeRange(0x0080, 0x07ff, mNoOfBytes / 2 / 0x780);
|
makeUnicodeRange(0x0080, 0x07ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_bmp3() {
|
public void time_bmp3() {
|
||||||
makeUnicodeRange(
|
makeUnicodeRange(0x0800, 0xffff);
|
||||||
0x0800,
|
|
||||||
0xffff,
|
|
||||||
mNoOfBytes / 3 / 0xf000 /* 0x10000 - 0x0800 - no of surrogate code points */);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void time_supplementary() {
|
public void time_supplementary() {
|
||||||
makeUnicodeRange(0x10000, 0x10ffff, mNoOfBytes / 4 / 0x100000);
|
makeUnicodeRange(0x10000, 0x10ffff);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user