test/micro/org/openjdk/bench/java/lang/Clone.java
author neliasso
Thu, 31 Oct 2019 17:16:36 +0100
changeset 58931 304c63b17b07
parent 52595 16609197022c
permissions -rw-r--r--
8232896: ZGC: Enable C2 clone intrinsic Reviewed-by: pliden, kvn
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
52595
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     1
/*
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     2
 * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved.
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     4
 *
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     7
 * published by the Free Software Foundation.
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     8
 *
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    13
 * accompanied this code).
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    14
 *
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    18
 *
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    21
 * questions.
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    22
 */
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    23
package org.openjdk.bench.java.lang;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    24
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    25
import org.openjdk.jmh.annotations.Benchmark;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    26
import org.openjdk.jmh.annotations.BenchmarkMode;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    27
import org.openjdk.jmh.annotations.Mode;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    28
import org.openjdk.jmh.annotations.OutputTimeUnit;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    29
import org.openjdk.jmh.annotations.Scope;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    30
import org.openjdk.jmh.annotations.Setup;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    31
import org.openjdk.jmh.annotations.State;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    32
import org.openjdk.jmh.infra.Blackhole;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    33
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    34
import java.util.BitSet;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    35
import java.util.Date;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    36
import java.util.concurrent.TimeUnit;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    37
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    38
@BenchmarkMode(Mode.AverageTime)
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    39
@OutputTimeUnit(TimeUnit.NANOSECONDS)
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    40
@State(Scope.Thread)
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    41
public class Clone {
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    42
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    43
    private BitSet testObj1;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    44
    private Date testObj2;
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    45
    private char[] testObj3;
58931
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    46
    private char[] testObj4;
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    47
    private String[] testObj5;
52595
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    48
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    49
    @Setup
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    50
    public void setup() {
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    51
        testObj1 = new BitSet(10);
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    52
        testObj2 = new Date();
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    53
        testObj3 = new char[5];
58931
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    54
        testObj4 = new char[311];
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    55
        String str = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut";
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    56
        testObj5 = str.split(" ", -1);
52595
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    57
    }
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    58
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    59
    /** Calls clone on three different types. The types are java.util.BitSet, java.util.Date and char[]. */
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    60
    @Benchmark
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    61
    public void cloneThreeDifferent(Blackhole bh) {
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    62
        bh.consume(testObj1.clone());
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    63
        bh.consume(testObj2.clone());
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    64
        bh.consume(testObj3.clone());
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    65
    }
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    66
58931
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    67
    @Benchmark
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    68
    public void cloneLarge(Blackhole bh) {
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    69
        bh.consume(testObj4.clone());
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    70
        bh.consume(testObj5.clone());
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    71
    }
304c63b17b07 8232896: ZGC: Enable C2 clone intrinsic
neliasso
parents: 52595
diff changeset
    72
52595
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    73
}
16609197022c 8061281: Microbenchmark suite build support, directory layout and sample benchmarks
redestad
parents:
diff changeset
    74