Aurimas Liutikas | 88c7ff1 | 2023-08-10 12:42:26 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2022 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 | // This file is generated by generate_java.py do not directly modify! |
| 17 | package android.libcore.varhandles; |
| 18 | |
| 19 | import android.perftests.utils.BenchmarkState; |
| 20 | import android.perftests.utils.PerfStatusReporter; |
| 21 | import android.test.suitebuilder.annotation.LargeTest; |
| 22 | |
| 23 | import androidx.test.runner.AndroidJUnit4; |
| 24 | |
| 25 | import org.junit.Rule; |
| 26 | import org.junit.Test; |
| 27 | import org.junit.runner.RunWith; |
| 28 | |
| 29 | import java.lang.invoke.MethodHandles; |
| 30 | import java.lang.invoke.VarHandle; |
| 31 | |
| 32 | @RunWith(AndroidJUnit4.class) |
| 33 | @LargeTest |
| 34 | public class VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest { |
| 35 | @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter(); |
| 36 | static final int FIELD_VALUE = 42; |
| 37 | static int sField = FIELD_VALUE; |
| 38 | VarHandle mVh; |
| 39 | |
| 40 | public VarHandleGetandbitwiseAndReleaseStaticFieldLittleEndianIntPerfTest() throws Throwable { |
| 41 | mVh = MethodHandles.lookup().findStaticVarHandle(this.getClass(), "sField", int.class); |
| 42 | } |
| 43 | |
| 44 | @Test |
| 45 | public void run() { |
| 46 | int x; |
| 47 | BenchmarkState state = mPerfStatusReporter.getBenchmarkState(); |
| 48 | while (state.keepRunning()) { |
| 49 | x = (int) mVh.getAndBitwiseAndRelease(~42); |
| 50 | x = (int) mVh.getAndBitwiseAndRelease(~42); |
| 51 | } |
| 52 | } |
| 53 | } |