Debian Codegraph @

src/test/java/io/airlift/slice/BenchmarkHashCode.java

raw
1 /*
2 * Licensed under the Apache License, Version 2.0 (the "License");
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.apache.org/licenses/LICENSE-2.0
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 * See the License for the specific language governing permissions and
12 * limitations under the License.
13 */
14 package io.airlift.slice;
15
16 import org.openjdk.jmh.annotations.Fork;
17 import org.openjdk.jmh.annotations.Benchmark;
18 import org.openjdk.jmh.annotations.Measurement;
19 import org.openjdk.jmh.annotations.OutputTimeUnit;
20 import org.openjdk.jmh.annotations.Scope;
21 import org.openjdk.jmh.annotations.State;
22 import org.openjdk.jmh.annotations.Warmup;
23 import org.openjdk.jmh.runner.Runner;
24 import org.openjdk.jmh.runner.RunnerException;
25 import org.openjdk.jmh.runner.options.Options;
26 import org.openjdk.jmh.runner.options.OptionsBuilder;
27 import org.openjdk.jmh.runner.options.VerboseMode;
28
29 import java.util.concurrent.TimeUnit;
30
31 @State(Scope.Thread)
32 @OutputTimeUnit(TimeUnit.SECONDS)
33 @Fork(5)
34 @Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS)
35 @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS)
36 public class BenchmarkHashCode
37 {
38 @Benchmark
39 public long hash(BenchmarkData data, ByteCounter counter)
40 {
41 counter.add(data.getSlice().length());
42 return data.getSlice().hashCode(0, data.getSlice().length());
43 }
44
45 public static void main(String[] args)
46 throws RunnerException
47 {
48 Options options = new OptionsBuilder()
49 .verbosity(VerboseMode.NORMAL)
50 .include(".*" + BenchmarkHashCode.class.getSimpleName() + ".*")
51 .build();
52
53 new Runner(options).run();
54 }
55 }