view src/main/java/org/openjdk/gcbench/tenure/Arrays.java @ 56:c796a662ffba

Basic tenure tests.
author shade
date Mon, 19 Dec 2016 17:23:14 +0100
parents
children 1655f5729b5a
line wrap: on
line source

package org.openjdk.gcbench.tenure;

import org.openjdk.gcbench.alloc.uninit.AllocUninit;
import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(jvmArgsPrepend = {"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"})
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Threads(Threads.MAX)
@State(Scope.Thread)
public class Arrays {

    Object[] tenures;

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

    int idx;

    @Setup
    public void setup() {
        tenures = new Object[size];
    }

    @Benchmark
    public void test() {
        int cur = idx;
        tenures[cur] = AllocUninit.alloc(1000);
        if (cur + 1 < size) {
            idx = cur + 1;
        } else {
            idx = 0;
        }
    }

}