Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 13e69db0 authored by Miguel Aranda's avatar Miguel Aranda Committed by Gerrit Code Review
Browse files

Revert "Migrate libcore benchmarks to BenchmarkRule"

This reverts commit e292bf87.

Reason for revert: This has been causing failures and is not does not seem compatible with the CB dashboard

Change-Id: Iea68da6aae4d5cc4f72b65268e522e22e34b45fe
parent e292bf87
Loading
Loading
Loading
Loading
+11 −11
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.libcore;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -34,11 +34,11 @@ import org.junit.runner.RunWith;
public class AdditionPerfTest {

    @Rule
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    @Test
    public void timeAddConstantToLocalInt() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        int result = 0;
        while (state.keepRunning()) {
            result += 123;
@@ -46,7 +46,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddTwoLocalInts() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        int result = 0;
        int constant = 123;
        while (state.keepRunning()) {
@@ -55,7 +55,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddConstantToLocalLong() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        long result = 0;
        while (state.keepRunning()) {
            result += 123L;
@@ -63,7 +63,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddTwoLocalLongs() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        long result = 0;
        long constant = 123L;
        while (state.keepRunning()) {
@@ -72,7 +72,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddConstantToLocalFloat() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        float result = 0.0f;
        while (state.keepRunning()) {
            result += 123.0f;
@@ -80,7 +80,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddTwoLocalFloats() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        float result = 0.0f;
        float constant = 123.0f;
        while (state.keepRunning()) {
@@ -89,7 +89,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddConstantToLocalDouble() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        double result = 0.0;
        while (state.keepRunning()) {
            result += 123.0;
@@ -97,7 +97,7 @@ public class AdditionPerfTest {
    }
    @Test
    public void timeAddTwoLocalDoubles() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        double result = 0.0;
        double constant = 123.0;
        while (state.keepRunning()) {
+7 −7
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.libcore;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -33,11 +33,11 @@ import java.util.Arrays;
public class ArrayCopyPerfTest {

    @Rule
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    @Test
    public void timeManualArrayCopy() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        char[] src = new char[8192];
        while (state.keepRunning()) {
            char[] dst = new char[8192];
@@ -49,7 +49,7 @@ public class ArrayCopyPerfTest {

    @Test
    public void time_System_arrayCopy() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        char[] src = new char[8192];
        while (state.keepRunning()) {
            char[] dst = new char[8192];
@@ -59,7 +59,7 @@ public class ArrayCopyPerfTest {

    @Test
    public void time_Arrays_copyOf() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        char[] src = new char[8192];
        while (state.keepRunning()) {
            char[] dst = Arrays.copyOf(src, 8192);
@@ -68,7 +68,7 @@ public class ArrayCopyPerfTest {

    @Test
    public void time_Arrays_copyOfRange() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        char[] src = new char[8192];
        while (state.keepRunning()) {
            char[] dst = Arrays.copyOfRange(src, 0, 8192);
+6 −6
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.libcore;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -38,7 +38,7 @@ public class ArrayIterationPerfTest {
    }

    @Rule
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    Foo[] mArray = new Foo[27];
    {
@@ -46,7 +46,7 @@ public class ArrayIterationPerfTest {
    }
    @Test
    public void timeArrayIteration() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            int sum = 0;
            for (int i = 0; i < mArray.length; i++) {
@@ -56,7 +56,7 @@ public class ArrayIterationPerfTest {
    }
    @Test
    public void timeArrayIterationCached() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            int sum = 0;
            Foo[] localArray = mArray;
@@ -69,7 +69,7 @@ public class ArrayIterationPerfTest {
    }
    @Test
    public void timeArrayIterationForEach() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            int sum = 0;
            for (Foo a: mArray) {
+5 −5
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.libcore;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -39,7 +39,7 @@ public class ArrayListIterationPerfTest {
        int mSplat;
    }
    @Rule
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
    public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    ArrayList<Foo> mList = new ArrayList<Foo>();
    {
@@ -47,7 +47,7 @@ public class ArrayListIterationPerfTest {
    }
    @Test
    public void timeArrayListIterationIndexed() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            int sum = 0;
            ArrayList<Foo> list = mList;
@@ -59,7 +59,7 @@ public class ArrayListIterationPerfTest {
    }
    @Test
    public void timeArrayListIterationForEach() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            int sum = 0;
            for (Foo a : mList) {
+9 −10
Original line number Diff line number Diff line
@@ -16,8 +16,8 @@

package android.libcore;

import androidx.benchmark.BenchmarkState;
import androidx.benchmark.junit4.BenchmarkRule;
import android.perftests.utils.BenchmarkState;
import android.perftests.utils.PerfStatusReporter;

import androidx.test.filters.LargeTest;
import androidx.test.runner.AndroidJUnit4;
@@ -38,8 +38,7 @@ import java.math.BigInteger;
@RunWith(AndroidJUnit4.class)
@LargeTest
public class BigIntegerPerfTest {
    @Rule
    public BenchmarkRule mBenchmarkRule = new BenchmarkRule();
    @Rule public PerfStatusReporter mPerfStatusReporter = new PerfStatusReporter();

    // A simple sum of products computation, mostly so we can check timing in the
    // absence of any division. Computes the sum from 1 to n of ((10^prec) << 30) + 1)^2,
@@ -62,7 +61,7 @@ public class BigIntegerPerfTest {
    // Execute the above rep times, optionally timing it.
    @Test
    public void repeatInner() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 10; i <= 10_000; i *= 10) {
                inner(100, i);
@@ -86,7 +85,7 @@ public class BigIntegerPerfTest {
    // Check results for equality, and print one, to compaare against reference.
    @Test
    public void repeatHarmonic1000() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 5; i <= 5_000; i *= 10) {
                BigInteger refRes = harmonic1000(i);
@@ -107,7 +106,7 @@ public class BigIntegerPerfTest {
    // us to time and check it for consistency as well.
    @Test
    public void repeatToString() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 5; i <= 5_000; i *= 10) {
                BigInteger refRes = harmonic1000(i);
@@ -147,7 +146,7 @@ public class BigIntegerPerfTest {
    // to compare to reference.
    @Test
    public void repeatEApprox() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 10; i <= 10_000; i *= 10) {
                BigInteger refRes = eApprox(100_000, i);
@@ -166,7 +165,7 @@ public class BigIntegerPerfTest {
    // Test / time modPow()
    @Test
    public void repeatModPow() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 5; i <= 500; i *= 10) {
                BigInteger odd1 = BigInteger.TEN.pow(i / 2).add(BigInteger.ONE);
@@ -199,7 +198,7 @@ public class BigIntegerPerfTest {
    // Test / time modInverse()
    @Test
    public void repeatModInverse() {
        final BenchmarkState state = mBenchmarkRule.getState();
        BenchmarkState state = mPerfStatusReporter.getBenchmarkState();
        while (state.keepRunning()) {
            for (int i = 10; i <= 10_000; i *= 10) {
                BigInteger odd1 = BigInteger.TEN.pow(i / 2).add(BigInteger.ONE);
Loading