diff --git a/itests/hive-jmh/pom.xml b/itests/hive-jmh/pom.xml
index f3764c7..48257c4 100644
--- a/itests/hive-jmh/pom.xml
+++ b/itests/hive-jmh/pom.xml
@@ -58,6 +58,21 @@
hive-exec
${project.version}
+
+ org.apache.hive
+ hive-cli
+ ${project.version}
+
+
+ org.apache.hive
+ hive-cli
+ ${project.version}
+
+
+ org.apache.hive
+ hive-beeline
+ ${project.version}
+
diff --git a/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/cli/CliBench.java b/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/cli/CliBench.java
new file mode 100644
index 0000000..c1e629b
--- /dev/null
+++ b/itests/hive-jmh/src/main/java/org/apache/hive/benchmark/cli/CliBench.java
@@ -0,0 +1,112 @@
+/**
+ * Licensed 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.cli;
+
+import org.apache.hadoop.hive.cli.CliDriver;
+import org.openjdk.jmh.annotations.Benchmark;
+import org.openjdk.jmh.annotations.BenchmarkMode;
+import org.openjdk.jmh.annotations.Fork;
+import org.openjdk.jmh.annotations.Measurement;
+import org.openjdk.jmh.annotations.Mode;
+import org.openjdk.jmh.annotations.OutputTimeUnit;
+import org.openjdk.jmh.annotations.Scope;
+import org.openjdk.jmh.annotations.Setup;
+import org.openjdk.jmh.annotations.TearDown;
+import org.openjdk.jmh.annotations.State;
+import org.openjdk.jmh.runner.Runner;
+import org.openjdk.jmh.runner.options.Options;
+import org.openjdk.jmh.runner.options.OptionsBuilder;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
+@BenchmarkMode(Mode.AverageTime)
+@Fork(1)
+@State(Scope.Thread)
+@OutputTimeUnit(TimeUnit.NANOSECONDS)
+public abstract class CliBench {
+ final static String initialSql = "create table if not exists myTbl(k string,v string);";
+ final static String cleanupSql = "drop table if exists myTbl;";
+ protected File initialFile;
+
+ @Setup
+ public void setup() throws Exception {
+ generateInitialFile();
+ initialCli();
+ cleanupSql();
+ }
+
+ protected abstract void initialCli();
+
+ /**
+ * generate sql initial file
+ *
+ * @throws IOException
+ */
+ private void generateInitialFile() throws IOException {
+ String tmpBaseDir = System.getProperty("test.tmp.dir", "/tmp/");
+ initialFile = new File(tmpBaseDir, "initial.sql");
+ FileWriter initialFileWriter = new FileWriter(initialFile);
+ initialFileWriter.write(initialSql);
+ initialFileWriter.close();
+ }
+
+ abstract protected void cleanupSql() throws Exception;
+
+ @TearDown
+ public void cleanup() throws Exception {
+ initialFile.delete();
+ cleanupSql();
+ }
+
+ public static class CliDriverBench extends CliBench {
+ CliDriver cliDriver;
+
+ @Override
+ protected void initialCli() {
+ cliDriver = new CliDriver();
+ }
+
+ @Override
+ protected void cleanupSql() throws Exception {
+ cliDriver.run(new String[]{"-e", cleanupSql});
+ }
+
+ @Benchmark
+ @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
+ public void testOption() throws Exception {
+ cliDriver.run(new String[]{"-h"});
+ }
+
+ @Benchmark
+ @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
+ public void testSQLWithInitialFile() throws Exception {
+ cliDriver.run(new String[]{"-i", initialFile.getAbsolutePath(), "-e", "\"show tables;\""});
+ }
+
+ @Benchmark
+ @Measurement(iterations = 1, time = 1, timeUnit = TimeUnit.MILLISECONDS)
+ public void testSQLWithoutInitialFile() throws Exception {
+ cliDriver.run(new String[]{"-d", "a", "b", "-e", "\"show tables;\""});
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ Options opt = new OptionsBuilder().include(".*" + CliBench.class.getSimpleName() + ".*")
+ .warmupIterations(0).build();
+ new Runner(opt).run();
+ }
+}