/** * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.hive.benchmark.vectorization; import org.apache.hadoop.hive.ql.exec.vector.expressions.FilterStringColLikeStringScalar; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.State; import org.openjdk.jmh.runner.Runner; import org.openjdk.jmh.runner.RunnerException; import org.openjdk.jmh.runner.options.Options; import org.openjdk.jmh.runner.options.OptionsBuilder; import java.nio.charset.StandardCharsets; /** * This test measures the performance for vectorization. * <p/> * This test uses JMH framework for benchmarking. * You may execute this benchmark tool using JMH command line in different ways: * <p/> * To use the settings shown in the main() function, use: * $ java -cp target/benchmarks.jar org.apache.hive.benchmark.vectorization.VectorizedLikeBench * <p/> * To use the default settings used by JMH, use: * $ java -jar target/benchmarks.jar org.apache.hive.benchmark.vectorization.VectorizedLikeBench * <p/> * To specify different parameters, use: * - This command will use 10 warm-up iterations, 5 test iterations, and 2 forks. And it will * display the Average Time (avgt) in Microseconds (us) * - Benchmark mode. Available modes are: * [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all] * - Output time unit. Available time units are: [m, s, ms, us, ns]. * <p/> * $ java -jar target/benchmarks.jar org.apache.hive.benchmark.vectorization.VectorizedLikeBench * -wi 10 -i 5 -f 2 -bm avgt -tu us */ @State(Scope.Benchmark) public class VectorizedLikeBench { public static class FilterStringColLikeStringScalarBench extends AbstractExpression { @Override public void setup() { rowBatch = buildRowBatch(null, 1, getBytesColumnVector()); expression = new FilterStringColLikeStringScalar(0, "%aabb%".getBytes(StandardCharsets.UTF_8)); } } public static void main(String[] args) throws RunnerException { Options opt = new OptionsBuilder().include(".*" + VectorizedLikeBench.class.getSimpleName() + ".*").build(); new Runner(opt).run(); } }