view src/main/java/org/openjdk/gcbench/runtime/writes/Plain.java @ 74:1e757307727c

Make sure write tests are not sharing the instance.
author shade
date Wed, 26 Apr 2017 20:36:26 +0200
parents c65e5eaf3b0d
children 583fef4276f5
line wrap: on
line source

package org.openjdk.gcbench.runtime.writes;

import org.openjdk.jmh.annotations.*;

import java.util.concurrent.TimeUnit;

import static org.openjdk.gcbench.util.Sinks.sink;

@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@Threads(1)
@State(Scope.Thread)
public class Plain {

    Target target;

    @Setup
    public void setup() {
        target = new Target();
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_none() {
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_boolean() {
        target.f_boolean = true;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_byte() {
        target.f_byte = 42;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_char() {
        target.f_char = 'A';
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_short() {
        target.f_short = 42;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_int() {
        target.f_int = 42;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_float() {
        target.f_float = 42f;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_long() {
        target.f_long = 42L;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_double() {
        target.f_double = 42D;
    }

    @Benchmark
    @CompilerControl(CompilerControl.Mode.DONT_INLINE)
    public void test_Object() {
        target.f_Object = target;
    }

    static class Target {
        boolean f_boolean;
        byte f_byte;
        short f_short;
        char f_char;
        int f_int;
        float f_float;
        long f_long;
        double f_double;
        Object f_Object;
    }

}