Debian Codegraph @

apct-tests/perftests/core/src/android/os/ParcelStringPerfTest.java

raw symbols SCIP
1 /*
2 * Copyright (C) 2020 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package android.os;
18
19 import android.perftests.utils.BenchmarkState;
20 import android.perftests.utils.PerfStatusReporter;
21
22 import androidx.test.filters.LargeTest;
23
24 import org.junit.Rule;
25 import org.junit.Test;
26 import org.junit.runner.RunWith;
27 import org.junit.runners.Parameterized;
28
29 import java.util.Arrays;
30 import java.util.Collection;
31
32 @LargeTest
33 @RunWith(Parameterized.class)
34 public class ParcelStringPerfTest {
35 @Rule
36 public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();
37
38 @Parameterized.Parameter(0)
39 public String mName;
40 @Parameterized.Parameter(1)
41 public String mValue;
42
43 @Parameterized.Parameters(name = "{0}")
44 public static Collection<Object[]> getParameters() {
45 return Arrays.asList(new Object[][] {
46 { "simple", "com.example.typical_package_name" },
47 { "complex", "從不喜歡孤單一個 - 蘇永康/吳雨霏" },
48 });
49 }
50
51 @Test
52 public void timeWriteString8() {
53 final Parcel parcel = Parcel.obtain();
54 final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
55 while (state.keepRunning()) {
56 parcel.setDataPosition(0);
57 parcel.writeString8(mValue);
58 }
59 }
60
61 @Test
62 public void timeWriteString16() {
63 final Parcel parcel = Parcel.obtain();
64 final BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
65 while (state.keepRunning()) {
66 parcel.setDataPosition(0);
67 parcel.writeString16(mValue);
68 }
69 }
70 }