Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/jdk17u
Path: blob/master/test/micro/org/openjdk/bench/java/util/ArraysMismatchPartialInlining.java
66646 views
1
/*
2
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
*
5
* This code is free software; you can redistribute it and/or modify it
6
* under the terms of the GNU General Public License version 2 only, as
7
* published by the Free Software Foundation.
8
*
9
* This code is distributed in the hope that it will be useful, but WITHOUT
10
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12
* version 2 for more details (a copy is included in the LICENSE file that
13
* accompanied this code).
14
*
15
* You should have received a copy of the GNU General Public License version
16
* 2 along with this work; if not, write to the Free Software Foundation,
17
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18
*
19
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20
* or visit www.oracle.com if you need additional information or have any
21
* questions.
22
*/
23
package org.openjdk.bench.java.util;
24
25
import java.util.Arrays;
26
import java.util.concurrent.TimeUnit;
27
import org.openjdk.jmh.annotations.Benchmark;
28
import org.openjdk.jmh.annotations.BenchmarkMode;
29
import org.openjdk.jmh.annotations.Measurement;
30
import org.openjdk.jmh.annotations.Mode;
31
import org.openjdk.jmh.annotations.OutputTimeUnit;
32
import org.openjdk.jmh.annotations.Param;
33
import org.openjdk.jmh.annotations.Scope;
34
import org.openjdk.jmh.annotations.Setup;
35
import org.openjdk.jmh.annotations.State;
36
import org.openjdk.jmh.annotations.Warmup;
37
38
@BenchmarkMode(Mode.Throughput)
39
@OutputTimeUnit(TimeUnit.MILLISECONDS)
40
@State(Scope.Thread)
41
public class ArraysMismatchPartialInlining {
42
43
@Param({"3", "4", "5", "6", "7", "15", "31", "63", "95", "800"})
44
private static int size;
45
46
byte [] barray1;
47
char [] carray1;
48
short [] sarray1;
49
int [] iarray1;
50
long [] larray1;
51
float [] farray1;
52
double [] darray1;
53
54
byte [] barray2;
55
char [] carray2;
56
short [] sarray2;
57
int [] iarray2;
58
long [] larray2;
59
float [] farray2;
60
double [] darray2;
61
62
@Setup
63
public void setup() {
64
barray1 = new byte[size];
65
carray1 = new char[size];
66
sarray1 = new short[size];
67
iarray1 = new int[size];
68
larray1 = new long[size];
69
farray1 = new float[size];
70
darray1 = new double[size];
71
72
barray2 = new byte[size];
73
carray2 = new char[size];
74
sarray2 = new short[size];
75
iarray2 = new int[size];
76
larray2 = new long[size];
77
farray2 = new float[size];
78
darray2 = new double[size];
79
80
Arrays.fill(barray1 , (byte)0xF);
81
Arrays.fill(carray1 , (char)0xFF);
82
Arrays.fill(sarray1 , (short)0xFF);
83
Arrays.fill(iarray1 , -1);
84
Arrays.fill(larray1 , -1L);
85
Arrays.fill(farray1 , -1.0f);
86
Arrays.fill(darray1, -1.0);
87
88
Arrays.fill(barray2 , (byte)0xF);
89
Arrays.fill(carray2 , (char)0xFF);
90
Arrays.fill(sarray2 , (short)0xFF);
91
Arrays.fill(iarray2 , -1);
92
Arrays.fill(larray2 , -1L);
93
Arrays.fill(farray2 , -1.0F);
94
Arrays.fill(darray2, -1.0);
95
96
barray2[size-1] = (byte)1;
97
carray2[size-1] = (char)1;
98
sarray2[size-1] = (short)1;
99
iarray2[size-1] = 1;
100
larray2[size-1] = 1L;
101
farray2[size-1] = 1.0f;
102
darray2[size-1] = 1.0;
103
}
104
105
@Benchmark
106
public int testByteMatch() {
107
return Arrays.mismatch(barray1, barray2);
108
}
109
110
@Benchmark
111
public int testCharMatch() {
112
return Arrays.mismatch(carray1, carray2);
113
}
114
115
@Benchmark
116
public int testShortMatch() {
117
return Arrays.mismatch(sarray1, sarray2);
118
}
119
120
@Benchmark
121
public int testIntMatch() {
122
return Arrays.mismatch(iarray1, iarray2);
123
}
124
125
@Benchmark
126
public int testLongMatch() {
127
return Arrays.mismatch(larray1, larray2);
128
}
129
130
@Benchmark
131
public int testFloatMatch() {
132
return Arrays.mismatch(farray1, farray2);
133
}
134
135
@Benchmark
136
public int testDoubleMatch() {
137
return Arrays.mismatch(darray1, darray2);
138
}
139
}
140
141