view src/main/java/org/openjdk/gcbench/yield/ArrayIteration.java @ 83:659166b70dd9

Fixup ArrayIteration test units
author shade
date Thu, 26 Oct 2017 12:11:17 +0200
parents 5b77fb55a8b6
children 0cb1442be9d6
line wrap: on
line source

package org.openjdk.gcbench.yield;

import org.openjdk.gcbench.tests.UnderPressureTest;
import org.openjdk.jmh.annotations.*;
import org.openjdk.jmh.infra.Blackhole;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@Threads(Threads.MAX)
@State(Scope.Benchmark)
public class ArrayIteration extends UnderPressureTest {

    int[] arr;

    @Param({"100000"})
    int size;

    @Setup
    public void setup(Blackhole bh) {
        super.setup(bh);
        arr = new int[size];
    }

    @TearDown
    public void tearDown() throws InterruptedException {
        super.tearDown();
    }

    @Benchmark
    public int test() throws InterruptedException {
        int r = 0;
        for (int i : arr) {
            r = (i * 1664525 + 1013904223 + r) % 1000;
        }
        return r;
    }

}