impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tarmstr...@apache.org
Subject [2/2] incubator-impala git commit: Move all benchmarks to benchmark/ folder
Date Fri, 08 Jul 2016 09:42:02 GMT
Move all benchmarks to benchmark/ folder

This is just a cleanup patch. The immediate motivation is to exclude
them from code coverage reports.

Change-Id: I16d706a4f3f9f1c75f3047fca570d9fc86a46dc9
Reviewed-on: http://gerrit.cloudera.org:8080/3589
Reviewed-by: Michael Ho <kwho@cloudera.com>
Reviewed-by: Dan Hecht <dhecht@cloudera.com>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/667a778a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/667a778a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/667a778a

Branch: refs/heads/master
Commit: 667a778af134ac987a151055388a41bb8e208dc7
Parents: c7b7c3e
Author: Tim Armstrong <tarmstrong@cloudera.com>
Authored: Tue May 31 16:58:18 2016 -0700
Committer: Tim Armstrong <tarmstrong@cloudera.com>
Committed: Fri Jul 8 02:41:53 2016 -0700

----------------------------------------------------------------------
 be/CMakeLists.txt                           |   5 -
 be/src/benchmarks/CMakeLists.txt            |  12 +-
 be/src/benchmarks/expr-benchmark.cc         | 527 +++++++++++++++++++++++
 be/src/benchmarks/in-predicate-benchmark.cc | 332 ++++++++++++++
 be/src/benchmarks/network-perf-benchmark.cc | 243 +++++++++++
 be/src/exprs/CMakeLists.txt                 |   5 -
 be/src/exprs/expr-benchmark.cc              | 527 -----------------------
 be/src/exprs/in-predicate-benchmark.cc      | 332 --------------
 be/src/util/CMakeLists.txt                  |   2 -
 be/src/util/network-perf-benchmark.cc       | 243 -----------
 10 files changed, 1112 insertions(+), 1116 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt
index 3f0374b..5f5a72f 100644
--- a/be/CMakeLists.txt
+++ b/be/CMakeLists.txt
@@ -390,11 +390,6 @@ FUNCTION(ADD_UDF_TEST TEST_NAME)
   ADD_DEPENDENCIES(be-test ${TEST_NAME})
 ENDFUNCTION()
 
-FUNCTION(ADD_BE_BENCHMARK BENCHMARK_NAME)
-  ADD_EXECUTABLE(${BENCHMARK_NAME} ${BENCHMARK_NAME}.cc)
-  TARGET_LINK_LIBRARIES(${BENCHMARK_NAME} ${IMPALA_LINK_LIBS})
-ENDFUNCTION()
-
 # Function to generate rule to cross compile a source file to an IR module.
 # This should be called with the .cc src file and it will generate a
 # src-file-ir target that can be built.

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/benchmarks/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/be/src/benchmarks/CMakeLists.txt b/be/src/benchmarks/CMakeLists.txt
index 248b884..81ae18e 100644
--- a/be/src/benchmarks/CMakeLists.txt
+++ b/be/src/benchmarks/CMakeLists.txt
@@ -19,6 +19,11 @@ set(LIBRARY_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}/benchmarks")
 # where to put generated binaries
 set(EXECUTABLE_OUTPUT_PATH "${BUILD_OUTPUT_ROOT_DIRECTORY}/benchmarks")
 
+FUNCTION(ADD_BE_BENCHMARK BENCHMARK_NAME)
+  ADD_EXECUTABLE(${BENCHMARK_NAME} ${BENCHMARK_NAME}.cc)
+  TARGET_LINK_LIBRARIES(${BENCHMARK_NAME} ${IMPALA_LINK_LIBS})
+ENDFUNCTION()
+
 ADD_BE_BENCHMARK(parse-timestamp-benchmark)
 ADD_BE_BENCHMARK(string-search-benchmark)
 ADD_BE_BENCHMARK(atod-benchmark)
@@ -37,6 +42,9 @@ ADD_BE_BENCHMARK(overflow-benchmark)
 ADD_BE_BENCHMARK(bloom-filter-benchmark)
 ADD_BE_BENCHMARK(int-hash-benchmark)
 ADD_BE_BENCHMARK(bitmap-benchmark)
+ADD_BE_BENCHMARK(expr-benchmark)
+ADD_BE_BENCHMARK(hash-benchmark)
+ADD_BE_BENCHMARK(in-predicate-benchmark)
+ADD_BE_BENCHMARK(network-perf-benchmark)
 
-add_executable(hash-benchmark hash-benchmark.cc)
-target_link_libraries(hash-benchmark Experiments ${IMPALA_LINK_LIBS})
+target_link_libraries(hash-benchmark Experiments)

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/benchmarks/expr-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/benchmarks/expr-benchmark.cc b/be/src/benchmarks/expr-benchmark.cc
new file mode 100644
index 0000000..91f89b5
--- /dev/null
+++ b/be/src/benchmarks/expr-benchmark.cc
@@ -0,0 +1,527 @@
+#include <stdio.h>
+#include <iostream>
+
+#include <jni.h>
+#include <thrift/Thrift.h>
+#include <thrift/protocol/TDebugProtocol.h>
+
+#include "exprs/expr.h"
+#include "exprs/expr-context.h"
+#include "util/benchmark.h"
+#include "util/cpu-info.h"
+#include "util/debug-util.h"
+#include "rpc/jni-thrift-util.h"
+
+#include "gen-cpp/Types_types.h"
+#include "gen-cpp/ImpalaService.h"
+#include "gen-cpp/DataSinks_types.h"
+#include "gen-cpp/Types_types.h"
+#include "gen-cpp/ImpalaService.h"
+#include "gen-cpp/ImpalaService_types.h"
+#include "gen-cpp/ImpalaInternalService.h"
+#include "gen-cpp/Frontend_types.h"
+#include "gen-cpp/ImpalaService.h"
+#include "gen-cpp/ImpalaInternalService.h"
+#include "gen-cpp/Frontend_types.h"
+#include "rpc/thrift-server.h"
+#include "common/object-pool.h"
+#include "common/status.h"
+#include "runtime/mem-tracker.h"
+#include "service/impala-server.h"
+
+#include "common/names.h"
+
+using namespace apache::thrift;
+using namespace impala;
+
+// Utility class to take (ascii) sql and return the plan.  This does minimal
+// error handling.
+class Planner {
+ public:
+  Planner() {
+    JNIEnv* jni_env = getJNIEnv();
+    // create instance of java class JniFrontend
+    jclass fe_class = jni_env->FindClass("com/cloudera/impala/service/JniFrontend");
+    jmethodID fe_ctor = jni_env->GetMethodID(fe_class, "<init>", "(Z)V");
+    EXIT_IF_EXC(jni_env);
+    create_exec_request_id_ =
+        jni_env->GetMethodID(fe_class, "createExecRequest", "([B)[B");
+    EXIT_IF_EXC(jni_env);
+
+    jboolean lazy = true;
+    jobject fe = jni_env->NewObject(fe_class, fe_ctor, lazy);
+    EXIT_IF_EXC(jni_env);
+    ABORT_IF_ERROR(JniUtil::LocalToGlobalRef(jni_env, fe, &fe_));
+  }
+
+  Status GeneratePlan(const string& stmt, TExecRequest* result) {
+    TQueryCtx query_ctx;
+    query_ctx.request.stmt = stmt;
+    query_ctx.request.query_options = query_options_;
+    query_ctx.__set_session(session_state_);
+    ImpalaServer::PrepareQueryContext(&query_ctx);
+
+    JNIEnv* jni_env = getJNIEnv();
+    JniLocalFrame jni_frame;
+    RETURN_IF_ERROR(jni_frame.push(jni_env));
+    jbyteArray request_bytes;
+    RETURN_IF_ERROR(SerializeThriftMsg(jni_env, &query_ctx, &request_bytes));
+    jbyteArray result_bytes = static_cast<jbyteArray>(
+        jni_env->CallObjectMethod(fe_, create_exec_request_id_, request_bytes));
+    RETURN_ERROR_IF_EXC(jni_env);
+    RETURN_IF_ERROR(DeserializeThriftMsg(jni_env, result_bytes, result));
+    return Status::OK();
+  }
+
+ private:
+  jobject fe_;  // instance of com.cloudera.impala.service.JniFrontend
+  jmethodID create_exec_request_id_;  // JniFrontend.createExecRequest()
+
+  TQueryOptions query_options_;
+  TSessionState session_state_;
+};
+
+struct TestData {
+  ExprContext* ctx;
+  int64_t dummy_result;
+};
+
+Planner planner;
+ObjectPool pool;
+MemTracker tracker;
+
+// Utility function to get prepare select list for exprs.  Assumes this is a
+// constant query
+static Status PrepareSelectList(const TExecRequest& request, ExprContext** ctx) {
+  const TQueryExecRequest& query_request = request.query_exec_request;
+  vector<TExpr> texprs = query_request.fragments[0].output_exprs;
+  DCHECK_EQ(texprs.size(), 1);
+  RETURN_IF_ERROR(Expr::CreateExprTree(&pool, texprs[0], ctx));
+  RETURN_IF_ERROR((*ctx)->Prepare(NULL, RowDescriptor(), &tracker));
+  return Status::OK();
+}
+
+// TODO: handle codegen.  Codegen needs a new driver that is also codegen'd.
+static TestData* GenerateBenchmarkExprs(const string& query, bool codegen) {
+  stringstream ss;
+  ss << "select " << query;
+  TestData* test_data = new TestData;
+  TExecRequest request;
+  ABORT_IF_ERROR(planner.GeneratePlan(ss.str(), &request));
+  ABORT_IF_ERROR(PrepareSelectList(request, &test_data->ctx));
+  return test_data;
+}
+
+const int ITERATIONS = 256;
+
+// Benchmark driver to run expr multiple times.
+void BenchmarkQueryFn(int batch_size, void* d) {
+  TestData* data = reinterpret_cast<TestData*>(d);
+  for (int i = 0; i < batch_size; ++i) {
+    for (int n = 0; n < ITERATIONS; ++n) {
+      void* value = data->ctx->GetValue(NULL);
+      // Dummy result to prevent this from being optimized away
+      data->dummy_result += reinterpret_cast<int64_t>(value);
+    }
+  }
+}
+
+#define BENCHMARK(name, stmt)\
+  suite->AddBenchmark(name, BenchmarkQueryFn, GenerateBenchmarkExprs(stmt, false))
+// Machine Info: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
+// Literals:             Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                            int                2154                  1X
+//                          float                2155              1.001X
+//                         double                2179              1.011X
+//                         string                2179              1.011X
+Benchmark* BenchmarkLiterals() {
+  Benchmark* suite = new Benchmark("Literals");
+  BENCHMARK("int", "1");
+  BENCHMARK("float", "1.1f");
+  BENCHMARK("double", "1.1");
+  BENCHMARK("string", "'1.1'");
+  return suite;
+}
+
+// Arithmetic:           Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                        int-add               527.5                  1X
+//                     double-add                 528              1.001X
+Benchmark* BenchmarkArithmetic() {
+  Benchmark* suite = new Benchmark("Arithmetic");
+  BENCHMARK("int-add", "1 + 2");
+  BENCHMARK("double-add", "1.1 + 2.2");
+  return suite;
+}
+
+// Machine Info: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
+// Like:                 Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                         equals               203.9                  1X
+//                     not equals               426.4              2.091X
+//                         strstr               142.8             0.7001X
+//                       strncmp1               269.7              1.323X
+//                       strncmp2               294.1              1.442X
+//                       strncmp3               775.7              3.804X
+//                          regex                19.7             0.0966X
+Benchmark* BenchmarkLike() {
+  Benchmark* suite = new Benchmark("Like");
+  BENCHMARK("equals", "'abcdefghijklmnopqrstuvwxyz' = 'abcdefghijklmnopqrstuvwxyz'");
+  BENCHMARK("not equals", "'abcdefghijklmnopqrstuvwxyz' = 'lmnopqrstuvwxyz'");
+  BENCHMARK("strstr", "'abcdefghijklmnopqrstuvwxyz' LIKE '%lmnopq%'");
+  BENCHMARK("strncmp1", "'abcdefghijklmnopqrstuvwxyz' LIKE '%xyz'");
+  BENCHMARK("strncmp2", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc%'");
+  BENCHMARK("strncmp3", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc'");
+  BENCHMARK("regex", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc%z'");
+  return suite;
+}
+
+// Cast:                 Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                     int_to_int                 824                  1X
+//                    int_to_bool                 878              1.066X
+//                  int_to_double               775.4              0.941X
+//                  int_to_string               32.47            0.03941X
+//              double_to_boolean               823.5             0.9994X
+//               double_to_bigint               775.4              0.941X
+//               double_to_string               4.682           0.005682X
+//                  string_to_int               402.6             0.4886X
+//                string_to_float               145.8             0.1769X
+//            string_to_timestamp               83.76             0.1017X
+Benchmark* BenchmarkCast() {
+  Benchmark* suite = new Benchmark("Cast");
+  BENCHMARK("int_to_int", "cast(1 as INT)");
+  BENCHMARK("int_to_bool", "cast(1 as BOOLEAN)");
+  BENCHMARK("int_to_double", "cast(1 as DOUBLE)");
+  BENCHMARK("int_to_string", "cast(1 as STRING)");
+  BENCHMARK("double_to_boolean", "cast(3.14 as BOOLEAN)");
+  BENCHMARK("double_to_bigint", "cast(3.14 as BIGINT)");
+  BENCHMARK("double_to_string", "cast(3.14 as STRING)");
+  BENCHMARK("string_to_int", "cast('1234' as INT)");
+  BENCHMARK("string_to_float", "cast('1234.5678' as FLOAT)");
+  BENCHMARK("string_to_timestamp", "cast('2011-10-22 09:10:11' as TIMESTAMP)");
+  return suite;
+}
+
+// ConditionalFunctions: Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                       not_null               877.8                  1X
+//                        is null               938.3              1.069X
+//                       compound               240.2             0.2736X
+//                    int_between                 191             0.2176X
+//              timestamp_between                18.5            0.02108X
+//                 string_between               93.94              0.107X
+//                        bool_in               356.6             0.4063X
+//                         int_in               209.7             0.2389X
+//                       float_in               216.4             0.2465X
+//                      string_in               120.1             0.1368X
+//                   timestamp_in               19.79            0.02255X
+//                         if_int               506.8             0.5773X
+//                      if_string               470.6             0.5361X
+//                   if_timestamp               70.19            0.07996X
+//                  coalesce_bool               194.2             0.2213X
+//                       case_int                 259             0.2951X
+Benchmark* BenchmarkConditionalFunctions() {
+// TODO: expand these cases when the parser issues are fixed (see corresponding tests
+// in expr-test).
+  Benchmark* suite = new Benchmark("ConditionalFunctions");
+  BENCHMARK("not_null", "!NULL");
+  BENCHMARK("is null", "5 IS NOT NULL");
+  BENCHMARK("compound", "(TRUE && TRUE) || FALSE");
+  BENCHMARK("int_between", "5 between 5 and 6");
+  BENCHMARK("timestamp_between", "cast('2011-10-22 09:10:11' as timestamp) between "
+      "cast('2011-09-22 09:10:11' as timestamp) and "
+      "cast('2011-12-22 09:10:11' as timestamp)");
+  BENCHMARK("string_between", "'abc' between 'aaa' and 'aab'");
+  BENCHMARK("bool_in", "true in (true, false, false)");
+  BENCHMARK("int_in", "1 in (2, 3, 1)");
+  BENCHMARK("float_in","1.1 not in (2, 3, 4.5)");
+  BENCHMARK("string_in", "'ab' in ('cd', 'efg', 'ab', 'h')");
+  BENCHMARK("timestamp_in", "cast('2011-11-23' as timestamp) "
+        "in (cast('2011-11-22 09:10:11' as timestamp), "
+        "cast('2011-11-23 09:11:12' as timestamp), "
+        "cast('2011-11-24 09:12:13' as timestamp))");
+  BENCHMARK("if_int", "if(TRUE, 10, 20)");
+  BENCHMARK("if_string", "if(TRUE, 'abc', 'defgh')");
+  BENCHMARK("if_timestamp", "if(TRUE, cast('2011-01-01 09:01:01' as timestamp), "
+      "cast('1999-06-14 19:07:25' as timestamp))");
+  BENCHMARK("coalesce_bool", "coalesce(if(true, NULL, NULL), if(true, NULL, NULL))");
+  BENCHMARK("case_int", "case 21 when 20 then 1 when 19 then 2 when 21 then 3 end");
+  return suite;
+}
+
+// StringFunctions:      Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                         length               920.2                  1X
+//                     substring1               351.4             0.3819X
+//                     substring2               327.9             0.3563X
+//                           left               508.6             0.5527X
+//                          right               508.2             0.5522X
+//                          lower               103.9             0.1129X
+//                          upper               103.2             0.1121X
+//                        reverse               324.9             0.3531X
+//                           trim               421.2             0.4578X
+//                          ltrim               526.6             0.5723X
+//                          rtrim               566.5             0.6156X
+//                          space               94.63             0.1028X
+//                          ascii                1048              1.139X
+//                          instr               175.6             0.1909X
+//                         locate               184.7             0.2007X
+//                        locate2               175.8             0.1911X
+//                         concat               109.5              0.119X
+//                        concat2               75.83            0.08241X
+//                       concatws               143.4             0.1559X
+//                      concatws2               70.38            0.07649X
+//                         repeat               98.54             0.1071X
+//                           lpad               154.7             0.1681X
+//                           rpad               145.6             0.1582X
+//                    find_in_set               83.38            0.09061X
+//                 regexp_extract                6.42           0.006977X
+//                 regexp_replace              0.7435           0.000808X
+Benchmark* BenchmarkStringFunctions() {
+  Benchmark* suite = new Benchmark("StringFunctions");
+  BENCHMARK("length", "length('Hello World!')");
+  BENCHMARK("substring1", "substring('Hello World!', 5)");
+  BENCHMARK("substring2", "substring('Hello World!', 5, 5)");
+  BENCHMARK("left", "strleft('Hello World!', 7)");
+  BENCHMARK("right", "strleft('Hello World!', 7)");
+  BENCHMARK("lower", "lower('Hello World!')");
+  BENCHMARK("upper", "upper('Hello World!')");
+  BENCHMARK("reverse", "reverse('Hello World!')");
+  BENCHMARK("trim", "trim('  Hello World!  ')");
+  BENCHMARK("ltrim", "ltrim('  Hello World!  ')");
+  BENCHMARK("rtrim", "rtrim('  Hello World!  ')");
+  BENCHMARK("space", "space(7)");
+  BENCHMARK("ascii", "ascii('abcd')");
+  BENCHMARK("instr", "instr('xyzabc', 'abc')");
+  BENCHMARK("locate", "locate('abc', 'xyzabc')");
+  BENCHMARK("locate2", "locate('abc', 'abcxyzabc', 3)");
+  BENCHMARK("concat", "concat('a', 'bcd')");
+  BENCHMARK("concat2", "concat('a', 'bb', 'ccc', 'dddd')");
+  BENCHMARK("concatws", "concat_ws('a', 'b')");
+  BENCHMARK("concatws2", "concat_ws('a', 'b', 'c', 'd')");
+  BENCHMARK("repeat", "repeat('abc', 7)");
+  BENCHMARK("lpad", "lpad('abc', 7, 'xyz')");
+  BENCHMARK("rpad", "rpad('abc', 7, 'xyz')");
+  BENCHMARK("find_in_set", "find_in_set('ab', 'abc,ad,ab,ade,cde')");
+  BENCHMARK("regexp_extract", "regexp_extract('abxcy1234a', 'a.x.y.*a', 0)");
+  BENCHMARK("regexp_replace", "regexp_replace('axcaycazc', '', 'r')");
+  return suite;
+}
+
+// UrlFunctions:         Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                      authority               118.1                  1X
+//                           file               95.52              0.809X
+//                           host               94.52             0.8005X
+//                           path               98.63             0.8353X
+//                       protocol               36.29             0.3073X
+//                           user               121.1              1.026X
+//                      user_info               121.4              1.029X
+//                     query_name               41.34             0.3501X
+Benchmark* BenchmarkUrlFunctions() {
+  Benchmark* suite = new Benchmark("UrlFunctions");
+  BENCHMARK("authority", "parse_url('http://user:pass@example.com:80/docs/books/tutorial/"
+      "index.html?name=networking#DOWNLOADING', 'AUTHORITY')");
+  BENCHMARK("file", "parse_url('http://example.com/docs/books/tutorial/"
+      "index.html?name=networking   ', 'FILE')");
+  BENCHMARK("host", "parse_url('http://example.com:80/docs/books/tutorial/"
+      "index.html?name=networking#DOWNLOADING', 'HOST')");
+  BENCHMARK("path", "parse_url('http://user:pass@example.com/docs/books/tutorial/"
+      "index.html?name=networking#DOWNLOADING', 'PATH')");
+  BENCHMARK("protocol", "parse_url('user:pass@example.com/docs/books/tutorial/"
+      "index.html?name=networking#DOWNLOADING', 'PROTOCOL')");
+  BENCHMARK("user", "parse_url('http://user@example.com/docs/books/tutorial/"
+        "index.html?name=networking#DOWNLOADING', 'USERINFO')");
+  BENCHMARK("user_info", "parse_url('http://user:pass@example.com:80/docs/books/tutorial/"
+      "index.html?name=networking#DOWNLOADING', 'USERINFO')");
+  BENCHMARK("query_name", "parse_url('http://example.com:80/docs/books/tutorial/"
+      "index.htmltest=true&name=networking&op=true', 'QUERY', 'name')");
+  return suite;
+}
+
+// MathFunctions:        Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                             pi                1642                  1X
+//                              e                1546             0.9416X
+//                            abs                 877             0.5342X
+//                             ln               110.7            0.06744X
+//                          log10               88.48             0.0539X
+//                           log2               108.3            0.06597X
+//                            log               55.61            0.03387X
+//                            pow               53.93            0.03285X
+//                           sqrt               629.6             0.3835X
+//                           sign                 732             0.4459X
+//                            sin               176.3             0.1074X
+//                           asin               169.6             0.1033X
+//                            cos               156.3             0.0952X
+//                           acos               167.5              0.102X
+//                            tan               176.3             0.1074X
+//                           atan               153.8            0.09371X
+//                        radians               601.5             0.3664X
+//                        degrees               601.5             0.3664X
+//                            bin                  45            0.02741X
+//                       pmod_int               147.3            0.08976X
+//                     pmod_float               172.9             0.1053X
+//                       positive                 877             0.5342X
+//                       negative               936.9             0.5707X
+//                           ceil               466.7             0.2843X
+//                          floor               390.9             0.2381X
+//                          round               820.5             0.4998X
+//                         round2               220.2             0.1341X
+//                        hex_int               5.745             0.0035X
+//                     hex_string               4.441           0.002705X
+//                          unhex               3.394           0.002067X
+//                       conv_int               33.15            0.02019X
+//                    conv_string                36.6            0.02229X
+Benchmark* BenchmarkMathFunctions() {
+  Benchmark* suite = new Benchmark("MathFunctions");
+  BENCHMARK("pi", "pi()");
+  BENCHMARK("e", "e()");
+  BENCHMARK("abs", "abs(-1.0)");
+  BENCHMARK("ln", "ln(3.14)");
+  BENCHMARK("log10", "log10(3.14)");
+  BENCHMARK("log2", "log2(3.14)");
+  BENCHMARK("log", "log(3.14, 5)");
+  BENCHMARK("pow", "pow(3.14, 5)");
+  BENCHMARK("sqrt", "sqrt(3.14)");
+  BENCHMARK("sign", "sign(1.0)");
+  BENCHMARK("sin", "sin(3.14)");
+  BENCHMARK("asin", "asin(3.14)");
+  BENCHMARK("cos", "cos(3.14)");
+  BENCHMARK("acos", "acos(3.14)");
+  BENCHMARK("tan", "tan(3.14)");
+  BENCHMARK("atan", "atan(3.14)");
+  BENCHMARK("radians", "radians(3.14)");
+  BENCHMARK("degrees", "degrees(3.14)");
+  BENCHMARK("bin", "bin(12345)");
+  BENCHMARK("pmod_int", "pmod(12345, 12)");
+  BENCHMARK("pmod_float", "pmod(12345.678, 12.34)");
+  BENCHMARK("positive", "positive(12345)");
+  BENCHMARK("negative", "negative(12345)");
+  BENCHMARK("ceil", "ceil(-10.05)");
+  BENCHMARK("floor", "floor(-10.05)");
+  BENCHMARK("round", "round(-10.05)");
+  BENCHMARK("round2", "round(-10.056789, 4)");
+  BENCHMARK("hex_int", "hex(16)");
+  BENCHMARK("hex_string", "hex('impala')");
+  BENCHMARK("unhex", "hex('496D70616C61')");
+  BENCHMARK("conv_int", "conv(100101, 2, 36)");
+  BENCHMARK("conv_string", "conv('100101', 2, 36)");
+  return suite;
+}
+
+// TimestampFunctions:   Function                Rate          Comparison
+// ----------------------------------------------------------------------
+//                        literal               68.18                  1X
+//                      to_string               1.131            0.01659X
+//                       add_year               34.57              0.507X
+//                      sub_month               33.04             0.4846X
+//                      add_weeks               56.15             0.8236X
+//                       sub_days               57.21             0.8391X
+//                            add               55.85             0.8191X
+//                      sub_hours               44.44             0.6519X
+//                    add_minutes               43.96             0.6448X
+//                    sub_seconds               42.78             0.6274X
+//                      add_milli               43.43             0.6371X
+//                      sub_micro               43.88             0.6436X
+//                       add_nano               41.83             0.6135X
+//                unix_timestamp1               32.74             0.4803X
+//                unix_timestamp2               39.39             0.5778X
+//                     from_unix1               1.192            0.01748X
+//                     from_unix2               1.602             0.0235X
+//                           year                73.4              1.077X
+//                          month               72.53              1.064X
+//                   day of month               71.98              1.056X
+//                    day of year               56.67             0.8312X
+//                   week of year               50.68             0.7433X
+//                           hour               100.1              1.468X
+//                         minute               97.18              1.425X
+//                         second                96.7              1.418X
+//                        to date               3.075            0.04511X
+//                      date diff               39.54             0.5799X
+Benchmark* BenchmarkTimestampFunctions() {
+  Benchmark* suite = new Benchmark("TimestampFunctions");
+  BENCHMARK("literal", "cast('2012-01-01 09:10:11.123456789' as timestamp)");
+  BENCHMARK("to_string",
+      "cast(cast('2012-01-01 09:10:11.123456789' as timestamp) as string)");
+  BENCHMARK("add_year", "date_add(cast('2012-01-01 09:10:11.123456789' "
+      "as timestamp), interval 10 years)");
+  BENCHMARK("sub_month", "date_sub(cast('2012-02-29 09:10:11.123456789' "
+      "as timestamp), interval 1 month)");
+  BENCHMARK("add_weeks", "date_add(cast('2012-01-01 09:10:11.123456789' "
+      "as timestamp), interval 53 weeks)");
+  BENCHMARK("sub_days", "date_sub(cast('2011-12-22 09:10:11.12345678' "
+      "as timestamp), interval 365 days)");
+  BENCHMARK("add", "date_add(cast('2012-01-01 09:10:11.123456789' "
+      "as timestamp), 10)");
+  BENCHMARK("sub_hours", "date_sub(cast('2012-01-02 01:00:00.123456789' "
+      "as timestamp), interval 25 hours)");
+  BENCHMARK("add_minutes", "date_add(cast('2012-01-01 00:00:00.123456789' "
+      "as timestamp), interval 1533 minutes)");
+  BENCHMARK("sub_seconds", "date_sub(cast('2012-01-02 01:00:33.123456789' "
+      "as timestamp), interval 90033 seconds)");
+  BENCHMARK("add_milli", "date_add(cast('2012-01-01 00:00:00.000000001' "
+      "as timestamp), interval 90000033 milliseconds)");
+  BENCHMARK("sub_micro", "date_sub(cast('2012-01-01 00:00:00.001033001' "
+      "as timestamp), interval 1033 microseconds)");
+  BENCHMARK("add_nano", "date_add(cast('2012-01-01 00:00:00.000000001' "
+      "as timestamp), interval 1033 nanoseconds)");
+  BENCHMARK("unix_timestamp1",
+      "unix_timestamp('1970-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')");
+  BENCHMARK("unix_timestamp2",
+      "unix_timestamp('1970-10-01', 'yyyy-MM-dd')");
+  BENCHMARK("from_unix1", "from_unixtime(0, 'yyyy-MM-dd HH:mm:ss')");
+  BENCHMARK("from_unix2", "from_unixtime(0, 'yyyy-MM-dd')");
+  BENCHMARK("year", "year(cast('2011-12-22' as timestamp))");
+  BENCHMARK("month", "month(cast('2011-12-22' as timestamp))");
+  BENCHMARK("day of month", "dayofmonth(cast('2011-12-22' as timestamp))");
+  BENCHMARK("day of year", "dayofyear(cast('2011-12-22' as timestamp))");
+  BENCHMARK("week of year", "weekofyear(cast('2011-12-22' as timestamp))");
+  BENCHMARK("hour", "hour(cast('09:10:11.000000' as timestamp))");
+  BENCHMARK("minute", "minute(cast('09:10:11.000000' as timestamp))");
+  BENCHMARK("second", "second(cast('09:10:11.000000' as timestamp))");
+  BENCHMARK("to date",
+      "to_date(cast('2011-12-22 09:10:11.12345678' as timestamp))");
+  BENCHMARK("date diff", "datediff(cast('2011-12-22 09:10:11.12345678' as timestamp), "
+      "cast('2012-12-22' as timestamp))");
+#if 0
+  // TODO: need to create a valid runtime state for these functions
+  BENCHMARK("from utc",
+      "from_utc_timestamp(cast(1.3041352164485E9 as timestamp), 'PST')");
+  BENCHMARK("to utc",
+      "to_utc_timestamp(cast('2011-01-01 01:01:01' as timestamp), 'PST')");
+  BENCHMARK("now", "now()");
+  BENCHMARK("unix_timestamp", "unix_timestamp()");
+#endif
+  return suite;
+}
+
+int main(int argc, char** argv) {
+  CpuInfo::Init();
+
+  // Generate all the tests first (this does the planning)
+  Benchmark* literals = BenchmarkLiterals();
+  Benchmark* arithmetics = BenchmarkArithmetic();
+  Benchmark* like = BenchmarkLike();
+  Benchmark* cast = BenchmarkCast();
+  Benchmark* conditional_fns = BenchmarkConditionalFunctions();
+  Benchmark* string_fns = BenchmarkStringFunctions();
+  Benchmark* url_fns = BenchmarkUrlFunctions();
+  Benchmark* math_fns = BenchmarkMathFunctions();
+  Benchmark* timestamp_fns = BenchmarkTimestampFunctions();
+
+  cout << Benchmark::GetMachineInfo() << endl;
+  cout << literals->Measure() << endl;
+  cout << arithmetics->Measure() << endl;
+  cout << like->Measure() << endl;
+  cout << cast->Measure() << endl;
+  cout << conditional_fns->Measure() << endl;
+  cout << string_fns->Measure() << endl;
+  cout << url_fns->Measure() << endl;
+  cout << math_fns->Measure() << endl;
+  cout << timestamp_fns->Measure() << endl;
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/benchmarks/in-predicate-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/benchmarks/in-predicate-benchmark.cc b/be/src/benchmarks/in-predicate-benchmark.cc
new file mode 100644
index 0000000..f337e1e
--- /dev/null
+++ b/be/src/benchmarks/in-predicate-benchmark.cc
@@ -0,0 +1,332 @@
+// Copyright 2015 Cloudera Inc.
+//
+// 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.
+
+
+// Note: The results do not include the pre-processing in the prepare function that is
+// necessary for SetLookup but not Iterate. None of the values searched for are in the
+// fabricated IN list (i.e. hit rate is 0).
+
+// Machine Info: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
+// int n=1:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=1               902.4                  1X
+//                    Iterate n=1               938.3               1.04X
+
+// int n=2:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=2               888.6                  1X
+//                    Iterate n=2               805.6             0.9066X
+
+// int n=3:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=3               806.5                  1X
+//                    Iterate n=3               744.1             0.9227X
+
+// int n=4:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=4               784.1                  1X
+//                    Iterate n=4                 661              0.843X
+
+// int n=5:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=5               801.6                  1X
+//                    Iterate n=5               594.4             0.7415X
+
+// int n=6:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=6               746.6                  1X
+//                    Iterate n=6                 539              0.722X
+
+// int n=7:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=7               683.4                  1X
+//                    Iterate n=7               493.9             0.7226X
+
+// int n=8:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=8                 772                  1X
+//                    Iterate n=8               455.5               0.59X
+
+// int n=9:              Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=9               702.9                  1X
+//                    Iterate n=9               420.1             0.5976X
+
+// int n=10:             Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                 SetLookup n=10               710.7                  1X
+//                   Iterate n=10               392.4             0.5521X
+
+// int n=400:            Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                SetLookup n=400               422.3                  1X
+//                  Iterate n=400               14.01            0.03318X
+
+
+// string n=1:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=1               250.8                  1X
+//                    Iterate n=1               540.4              2.154X
+
+// string n=2:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=2                 205                  1X
+//                    Iterate n=2               297.7              1.453X
+
+// string n=3:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=3               166.8                  1X
+//                    Iterate n=3               240.3              1.441X
+
+// string n=4:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=4               146.2                  1X
+//                    Iterate n=4               177.8              1.216X
+
+// string n=5:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=5               149.9                  1X
+//                    Iterate n=5               144.8             0.9662X
+
+// string n=6:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=6               135.9                  1X
+//                    Iterate n=6               127.4             0.9372X
+
+// string n=7:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=7               143.4                  1X
+//                    Iterate n=7               112.8             0.7866X
+
+// string n=8:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=8               123.7                  1X
+//                    Iterate n=8               117.1             0.9467X
+
+// string n=9:           Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=9                 117                  1X
+//                    Iterate n=9               89.19              0.762X
+
+// string n=10:          Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                 SetLookup n=10               125.4                  1X
+//                   Iterate n=10               81.63             0.6508X
+
+// string n=400:         Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                SetLookup n=400               55.77                  1X
+//                  Iterate n=400               1.936            0.03471X
+
+// decimal(4,0) n=1:     Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=1               587.9                  1X
+//                    Iterate n=1               658.3               1.12X
+
+// decimal(4,0) n=2:     Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=2               521.5                  1X
+//                    Iterate n=2               478.5             0.9175X
+
+// decimal(4,0) n=3:     Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=3                 524                  1X
+//                    Iterate n=3               373.7             0.7132X
+
+// decimal(4,0) n=4:     Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                  SetLookup n=4               486.6                  1X
+//                    Iterate n=4               308.9             0.6348X
+
+// decimal(4,0) n=400:   Function     Rate (iters/ms)          Comparison
+// ----------------------------------------------------------------------
+//                SetLookup n=400               258.2                  1X
+//                  Iterate n=400               4.272            0.01655X
+
+#include <boost/lexical_cast.hpp>
+#include <gutil/strings/substitute.h>
+
+#include "exprs/in-predicate.h"
+#include "exprs/in-predicate-ir.cc"
+
+#include "udf/udf-test-harness.h"
+#include "util/benchmark.h"
+#include "util/cpu-info.h"
+
+#include "common/names.h"
+
+using namespace impala;
+using namespace impala_udf;
+using namespace strings;
+
+namespace impala {
+
+template<typename T> T MakeAnyVal(int v) {
+  return T(v);
+}
+
+template<> StringVal MakeAnyVal(int v) {
+  // Leak these strings so we don't have to worry about them going out of scope
+  string* s = new string();
+  *s = lexical_cast<string>(v);
+  return StringVal(reinterpret_cast<uint8_t*>(const_cast<char*>(s->c_str())), s->size());
+}
+
+class InPredicateBenchmark {
+ public:
+  template<typename T, typename SetType>
+  struct TestData {
+    vector<T> anyvals;
+    vector<AnyVal*> anyval_ptrs;
+    InPredicate::SetLookupState<SetType> state;
+
+    vector<T> search_vals;
+
+    int total_found_set;
+    int total_set;
+    int total_found_iter;
+    int total_iter;
+  };
+
+  template<typename T, typename SetType>
+  static TestData<T, SetType> CreateTestData(int num_values,
+      const FunctionContext::TypeDesc& type, int num_search_vals = 100) {
+    srand(time(NULL));
+    TestData<T, SetType> data;
+    data.anyvals.resize(num_values);
+    data.anyval_ptrs.resize(num_values);
+    for (int i = 0; i < num_values; ++i) {
+      data.anyvals[i] = MakeAnyVal<T>(rand());
+      data.anyval_ptrs[i] = &data.anyvals[i];
+    }
+
+    for (int i = 0; i < num_search_vals; ++i) {
+      data.search_vals.push_back(MakeAnyVal<T>(rand()));
+    }
+
+    FunctionContext* ctx = CreateContext(num_values, type);
+
+    vector<AnyVal*> constant_args;
+    constant_args.push_back(NULL);
+    for (AnyVal* p: data.anyval_ptrs) constant_args.push_back(p);
+    UdfTestHarness::SetConstantArgs(ctx, constant_args);
+
+    InPredicate::SetLookupPrepare<T, SetType>(ctx, FunctionContext::FRAGMENT_LOCAL);
+    data.state = *reinterpret_cast<InPredicate::SetLookupState<SetType>*>(
+        ctx->GetFunctionState(FunctionContext::FRAGMENT_LOCAL));
+
+    data.total_found_set = data.total_set = data.total_found_iter = data.total_iter = 0;
+    return data;
+  }
+
+  template<typename T, typename SetType>
+  static void TestSetLookup(int batch_size, void* d) {
+    TestData<T, SetType>* data = reinterpret_cast<TestData<T, SetType>*>(d);
+    for (int i = 0; i < batch_size; ++i) {
+      for (const T& search_val: data->search_vals) {
+        BooleanVal found = InPredicate::SetLookup(&data->state, search_val);
+        if (found.val) ++data->total_found_set;
+        ++data->total_set;
+      }
+    }
+  }
+
+  template<typename T, typename SetType>
+  static void TestIterate(int batch_size, void* d) {
+    TestData<T, SetType>* data = reinterpret_cast<TestData<T, SetType>*>(d);
+    for (int i = 0; i < batch_size; ++i) {
+      for (const T& search_val: data->search_vals) {
+        BooleanVal found = InPredicate::Iterate(
+            data->state.type, search_val, data->anyvals.size(), &data->anyvals[0]);
+        if (found.val) ++data->total_found_iter;
+        ++data->total_iter;
+      }
+    }
+  }
+
+  static void RunIntBenchmark(int n) {
+    Benchmark suite(Substitute("int n=$0", n));
+    FunctionContext::TypeDesc type;
+    type.type = FunctionContext::TYPE_INT;
+    TestData<IntVal, int32_t> data =
+        InPredicateBenchmark::CreateTestData<IntVal, int32_t>(n, type);
+    suite.AddBenchmark(Substitute("SetLookup n=$0", n),
+                       InPredicateBenchmark::TestSetLookup<IntVal, int32_t>, &data);
+    suite.AddBenchmark(Substitute("Iterate n=$0", n),
+                       InPredicateBenchmark::TestIterate<IntVal, int32_t>, &data);
+    cout << suite.Measure() << endl;
+    // cout << "Found set: " << (double)data.total_found_set / data.total_set << endl;
+    // cout << "Found iter: " << (double)data.total_found_iter / data.total_iter << endl;
+  }
+
+  static void RunStringBenchmark(int n) {
+    Benchmark suite(Substitute("string n=$0", n));
+    FunctionContext::TypeDesc type;
+    type.type = FunctionContext::TYPE_STRING;
+    TestData<StringVal, StringValue> data =
+        InPredicateBenchmark::CreateTestData<StringVal, StringValue>(n, type);
+    suite.AddBenchmark(Substitute("SetLookup n=$0", n),
+                       InPredicateBenchmark::TestSetLookup<StringVal, StringValue>, &data);
+    suite.AddBenchmark(Substitute("Iterate n=$0", n),
+                       InPredicateBenchmark::TestIterate<StringVal, StringValue>, &data);
+    cout << suite.Measure() << endl;
+    // cout << "Found set: " << (double)data.total_found_set / data.total_set << endl;
+    // cout << "Found iter: " << (double)data.total_found_iter / data.total_iter << endl;
+  }
+
+  static void RunDecimalBenchmark(int n) {
+    Benchmark suite(Substitute("decimal(4,0) n=$0", n));
+    FunctionContext::TypeDesc type;
+    type.type = FunctionContext::TYPE_DECIMAL;
+    type.precision = 4;
+    type.scale = 0;
+    TestData<DecimalVal, Decimal16Value> data =
+        InPredicateBenchmark::CreateTestData<DecimalVal, Decimal16Value>(n, type);
+    suite.AddBenchmark(Substitute("SetLookup n=$0", n),
+                       InPredicateBenchmark::TestSetLookup<DecimalVal, Decimal16Value>, &data);
+    suite.AddBenchmark(Substitute("Iterate n=$0", n),
+                       InPredicateBenchmark::TestIterate<DecimalVal, Decimal16Value>, &data);
+    cout << suite.Measure() << endl;
+  }
+
+ private:
+  static FunctionContext* CreateContext(
+      int num_args, const FunctionContext::TypeDesc& type) {
+    // Types don't matter (but number of args do)
+    FunctionContext::TypeDesc ret_type;
+    vector<FunctionContext::TypeDesc> arg_types(num_args + 1, type);
+    return UdfTestHarness::CreateTestContext(ret_type, arg_types);
+  }
+
+};
+
+}
+
+int main(int argc, char **argv) {
+  CpuInfo::Init();
+  cout << Benchmark::GetMachineInfo() << endl;
+
+  for (int i = 1; i <= 10; ++i) InPredicateBenchmark::RunIntBenchmark(i);
+  InPredicateBenchmark::RunIntBenchmark(400);
+
+  cout << endl;
+
+  for (int i = 1; i <= 10; ++i) InPredicateBenchmark::RunStringBenchmark(i);
+  InPredicateBenchmark::RunStringBenchmark(400);
+
+  for (int i = 1; i <= 4; ++i) InPredicateBenchmark::RunDecimalBenchmark(i);
+  InPredicateBenchmark::RunDecimalBenchmark(400);
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/benchmarks/network-perf-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/benchmarks/network-perf-benchmark.cc b/be/src/benchmarks/network-perf-benchmark.cc
new file mode 100644
index 0000000..b218c97
--- /dev/null
+++ b/be/src/benchmarks/network-perf-benchmark.cc
@@ -0,0 +1,243 @@
+// Copyright 2012 Cloudera Inc.
+//
+// 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.
+
+#include <iostream>
+
+#include <thrift/protocol/TBinaryProtocol.h>
+#include <thrift/protocol/TDebugProtocol.h>
+#include <thrift/transport/TSocket.h>
+#include <thrift/transport/TTransportUtils.h>
+
+#include <boost/algorithm/string.hpp>
+#include <boost/thread/thread.hpp>
+#include "gen-cpp/NetworkTest_types.h"
+#include "gen-cpp/NetworkTestService.h"
+
+#include "common/logging.h"
+#include "util/cpu-info.h"
+#include "util/stopwatch.h"
+#include "rpc/thrift-client.h"
+#include "rpc/thrift-server.h"
+#include "rpc/thrift-thread.h"
+
+#include "common/names.h"
+
+DEFINE_int32(port, 22222, "Port for NetworkTestService");
+DEFINE_int64(send_batch_size, 0, "Batch size (in bytes).  Data is split up into batches");
+
+// Simple client server network speed benchmark utility.  This compiles to
+// a binary that runs as both the client and server.  The server can be started
+// up by just running the binary.  After the server starts up, it will drop into
+// the client 'shell' where benchmarks can be run.
+// The supported benchmarks are:
+//   'send <size in mb> <target ip>'
+//   'broadcast <size in mb> <list of space separated target ips>
+// The command can also be passed in via command line in the same format.  If
+// run in this mode, the server does not start up.
+// For broadcast, the data is sent in parallel to all nodes.
+//
+// The expected usage for measuring 'send' is to start up the server on one machine
+// and issue the send from another.
+// For 'broadcast', the server should be started on all the machines and then the
+// broadcast is issued from one of them.
+
+using boost::algorithm::is_any_of;
+using boost::algorithm::token_compress_on;
+using boost::algorithm::split;
+
+using namespace apache::thrift;
+using namespace apache::thrift::protocol;
+using namespace apache::thrift::transport;
+using namespace apache::thrift::server;
+using namespace apache::thrift::concurrency;
+using namespace impala;
+using namespace impalatest;
+
+
+class TestServer : public NetworkTestServiceIf {
+ public:
+  TestServer() {
+  }
+
+  virtual ~TestServer() {
+  }
+
+  virtual void Send(ThriftDataResult& result, const ThriftDataParams& params) {
+    result.__set_bytes_received(params.data.size());
+  }
+
+  void Server(ThriftServer* server) {
+    server->Start();
+    server->Join();
+  }
+};
+
+// Send bytes to client respecting the batch size
+// Returns the rate in mb/s to send the data.
+double Send(ThriftClient<NetworkTestServiceClient>* client, int64_t bytes) {
+  int64_t batch_size = FLAGS_send_batch_size;
+  if (batch_size == 0) batch_size = bytes;
+  int64_t total_sent = 0;
+
+  MonotonicStopWatch timer;
+  timer.Start();
+  while (total_sent < bytes) {
+    int64_t send_size = min(bytes - total_sent, batch_size);
+    total_sent += send_size;
+
+    ThriftDataParams data;
+    ThriftDataResult result;
+    data.data.resize(send_size);
+    client->iface()->Send(result, data);
+
+    if (result.bytes_received != send_size) {
+      return -1;
+    }
+  }
+  timer.Stop();
+
+  double mb = bytes / (1024. * 1024.);
+  double sec = timer.ElapsedTime() / (1000.) / (1000.) / (1000.);
+  return mb/sec;
+}
+
+// Send tokens[1] megabytes to tokens[2]
+void HandleSend(const vector<string>& tokens) {
+  if (tokens.size() != 3) {
+    return;
+  }
+
+  int64_t mbs = atoi(tokens[1].c_str());
+  int64_t bytes = mbs * (1024L * 1024L);
+  cout << "Sending " << mbs << " megabytes..." << endl;
+  const string& ip = tokens[2];
+
+  ThriftClient<NetworkTestServiceClient> client(ip, FLAGS_port);
+  Status status = client.Open();
+  if (!status.ok()) {
+    cerr << "Could not connect to server" << endl;
+    return;
+  }
+
+  double rate = Send(&client, bytes);
+  if (rate < 0) {
+    cerr << "Send failed";
+    return;
+  }
+  cout << "Send rate: (MB/s): " << rate << endl;
+}
+
+// Broadcast tokens[1] megabytes to tokens[2...n] nodes in parallel.
+void HandleBroadcast(const vector<string>& tokens) {
+  if (tokens.size() <= 2) {
+    return;
+  }
+  int64_t mbs = atoi(tokens[1].c_str());
+  int64_t bytes = mbs * (1024L * 1024L);
+  cout << "Broadcasting " << mbs << " megabytes..." << endl;
+
+  vector<ThriftClient<NetworkTestServiceClient>* > clients;
+  for (int i = 2; i < tokens.size(); ++i) {
+    ThriftClient<NetworkTestServiceClient>* client =
+        new ThriftClient<NetworkTestServiceClient>(tokens[i], FLAGS_port);
+    Status status = client->Open();
+    if (!status.ok()) {
+      cerr << "Could not connect to server: " << tokens[i] << endl;
+      return;
+    }
+    clients.push_back(client);
+  }
+
+  MonotonicStopWatch timer;
+  timer.Start();
+  thread_group threads;
+  for (int i = 0; i < clients.size(); ++i) {
+    threads.add_thread(new thread(Send, clients[i], bytes));
+  }
+  threads.join_all();
+  timer.Stop();
+
+  double mb = bytes / (1024 * 1024.);
+  double sec = timer.ElapsedTime() / (1000.) / (1000.) / (1000.);
+
+  cout << "Send rate per node: (MB/s) " << (mb/sec) << endl;
+  cout << "Send rate cluster: (MB/s) " << (mb * clients.size() / sec) << endl;
+}
+
+void ConvertToLowerCase(vector<string>* tokens) {
+  for (int i = 0; i < tokens->size(); ++i) {
+    transform(
+        (*tokens)[i].begin(), (*tokens)[i].end(), (*tokens)[i].begin(), ::tolower);
+  }
+}
+
+bool ProcessCommand(const vector<string>& tokens) {
+  if (tokens.empty()) return false;
+
+  if (tokens[0] == "quit") return true;;
+
+  if (tokens[0] == "send") {
+    HandleSend(tokens);
+  } else if (tokens[0] == "broadcast") {
+    HandleBroadcast(tokens);
+  } else {
+    cerr << "Invalid command" << endl;
+    return false;
+  }
+  return false;
+}
+
+int main(int argc, char** argv) {
+  google::ParseCommandLineFlags(&argc, &argv, true);
+  CpuInfo::Init();
+
+  if (argc != 1) {
+    // Just run client from command line args
+    vector<string> tokens;
+    for (int i = 1; i < argc; ++i) {
+      tokens.push_back(argv[i]);
+    }
+    ConvertToLowerCase(&tokens);
+    ProcessCommand(tokens);
+    return 0;
+  }
+
+  // Start up server and client shell
+  shared_ptr<TestServer> handler(new TestServer);
+  shared_ptr<ThreadFactory> thread_factory(new ThriftThreadFactory("test", "test"));
+  shared_ptr<TProcessor> processor(new NetworkTestServiceProcessor(handler));
+  ThriftServer* server = new ThriftServer("Network Test Server", processor,
+      FLAGS_port, NULL, NULL, 100, ThriftServer::ThreadPool);
+  thread* server_thread = new thread(&TestServer::Server, handler.get(), server);
+
+  string input;
+  while (1) {
+    vector<string> tokens;
+    cout << "> ";
+    cout.flush();
+
+    getline(cin, input);
+    if (cin.eof()) break;
+
+    split(tokens, input, is_any_of(" "), token_compress_on);
+
+    ConvertToLowerCase(&tokens);
+    if (ProcessCommand(tokens)) break;
+  }
+
+  server->StopForTesting();
+  server_thread->join();
+
+  return 0;
+}

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/exprs/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/be/src/exprs/CMakeLists.txt b/be/src/exprs/CMakeLists.txt
index 747add3..dd5ab13 100644
--- a/be/src/exprs/CMakeLists.txt
+++ b/be/src/exprs/CMakeLists.txt
@@ -56,9 +56,6 @@ add_library(Exprs
 )
 add_dependencies(Exprs thrift-deps gen_ir_descriptions)
 
-add_executable(expr-benchmark expr-benchmark.cc)
-target_link_libraries(expr-benchmark ${IMPALA_TEST_LINK_LIBS})
-
 ADD_BE_TEST(expr-test)
 ADD_BE_TEST(expr-codegen-test)
 
@@ -67,5 +64,3 @@ COMPILE_TO_IR(expr-codegen-test.cc)
 add_dependencies(expr-codegen-test-ir thrift-deps)
 
 ADD_UDF_TEST(aggregate-functions-test)
-
-ADD_BE_BENCHMARK(in-predicate-benchmark)

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/667a778a/be/src/exprs/expr-benchmark.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/expr-benchmark.cc b/be/src/exprs/expr-benchmark.cc
deleted file mode 100644
index 91f89b5..0000000
--- a/be/src/exprs/expr-benchmark.cc
+++ /dev/null
@@ -1,527 +0,0 @@
-#include <stdio.h>
-#include <iostream>
-
-#include <jni.h>
-#include <thrift/Thrift.h>
-#include <thrift/protocol/TDebugProtocol.h>
-
-#include "exprs/expr.h"
-#include "exprs/expr-context.h"
-#include "util/benchmark.h"
-#include "util/cpu-info.h"
-#include "util/debug-util.h"
-#include "rpc/jni-thrift-util.h"
-
-#include "gen-cpp/Types_types.h"
-#include "gen-cpp/ImpalaService.h"
-#include "gen-cpp/DataSinks_types.h"
-#include "gen-cpp/Types_types.h"
-#include "gen-cpp/ImpalaService.h"
-#include "gen-cpp/ImpalaService_types.h"
-#include "gen-cpp/ImpalaInternalService.h"
-#include "gen-cpp/Frontend_types.h"
-#include "gen-cpp/ImpalaService.h"
-#include "gen-cpp/ImpalaInternalService.h"
-#include "gen-cpp/Frontend_types.h"
-#include "rpc/thrift-server.h"
-#include "common/object-pool.h"
-#include "common/status.h"
-#include "runtime/mem-tracker.h"
-#include "service/impala-server.h"
-
-#include "common/names.h"
-
-using namespace apache::thrift;
-using namespace impala;
-
-// Utility class to take (ascii) sql and return the plan.  This does minimal
-// error handling.
-class Planner {
- public:
-  Planner() {
-    JNIEnv* jni_env = getJNIEnv();
-    // create instance of java class JniFrontend
-    jclass fe_class = jni_env->FindClass("com/cloudera/impala/service/JniFrontend");
-    jmethodID fe_ctor = jni_env->GetMethodID(fe_class, "<init>", "(Z)V");
-    EXIT_IF_EXC(jni_env);
-    create_exec_request_id_ =
-        jni_env->GetMethodID(fe_class, "createExecRequest", "([B)[B");
-    EXIT_IF_EXC(jni_env);
-
-    jboolean lazy = true;
-    jobject fe = jni_env->NewObject(fe_class, fe_ctor, lazy);
-    EXIT_IF_EXC(jni_env);
-    ABORT_IF_ERROR(JniUtil::LocalToGlobalRef(jni_env, fe, &fe_));
-  }
-
-  Status GeneratePlan(const string& stmt, TExecRequest* result) {
-    TQueryCtx query_ctx;
-    query_ctx.request.stmt = stmt;
-    query_ctx.request.query_options = query_options_;
-    query_ctx.__set_session(session_state_);
-    ImpalaServer::PrepareQueryContext(&query_ctx);
-
-    JNIEnv* jni_env = getJNIEnv();
-    JniLocalFrame jni_frame;
-    RETURN_IF_ERROR(jni_frame.push(jni_env));
-    jbyteArray request_bytes;
-    RETURN_IF_ERROR(SerializeThriftMsg(jni_env, &query_ctx, &request_bytes));
-    jbyteArray result_bytes = static_cast<jbyteArray>(
-        jni_env->CallObjectMethod(fe_, create_exec_request_id_, request_bytes));
-    RETURN_ERROR_IF_EXC(jni_env);
-    RETURN_IF_ERROR(DeserializeThriftMsg(jni_env, result_bytes, result));
-    return Status::OK();
-  }
-
- private:
-  jobject fe_;  // instance of com.cloudera.impala.service.JniFrontend
-  jmethodID create_exec_request_id_;  // JniFrontend.createExecRequest()
-
-  TQueryOptions query_options_;
-  TSessionState session_state_;
-};
-
-struct TestData {
-  ExprContext* ctx;
-  int64_t dummy_result;
-};
-
-Planner planner;
-ObjectPool pool;
-MemTracker tracker;
-
-// Utility function to get prepare select list for exprs.  Assumes this is a
-// constant query
-static Status PrepareSelectList(const TExecRequest& request, ExprContext** ctx) {
-  const TQueryExecRequest& query_request = request.query_exec_request;
-  vector<TExpr> texprs = query_request.fragments[0].output_exprs;
-  DCHECK_EQ(texprs.size(), 1);
-  RETURN_IF_ERROR(Expr::CreateExprTree(&pool, texprs[0], ctx));
-  RETURN_IF_ERROR((*ctx)->Prepare(NULL, RowDescriptor(), &tracker));
-  return Status::OK();
-}
-
-// TODO: handle codegen.  Codegen needs a new driver that is also codegen'd.
-static TestData* GenerateBenchmarkExprs(const string& query, bool codegen) {
-  stringstream ss;
-  ss << "select " << query;
-  TestData* test_data = new TestData;
-  TExecRequest request;
-  ABORT_IF_ERROR(planner.GeneratePlan(ss.str(), &request));
-  ABORT_IF_ERROR(PrepareSelectList(request, &test_data->ctx));
-  return test_data;
-}
-
-const int ITERATIONS = 256;
-
-// Benchmark driver to run expr multiple times.
-void BenchmarkQueryFn(int batch_size, void* d) {
-  TestData* data = reinterpret_cast<TestData*>(d);
-  for (int i = 0; i < batch_size; ++i) {
-    for (int n = 0; n < ITERATIONS; ++n) {
-      void* value = data->ctx->GetValue(NULL);
-      // Dummy result to prevent this from being optimized away
-      data->dummy_result += reinterpret_cast<int64_t>(value);
-    }
-  }
-}
-
-#define BENCHMARK(name, stmt)\
-  suite->AddBenchmark(name, BenchmarkQueryFn, GenerateBenchmarkExprs(stmt, false))
-// Machine Info: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
-// Literals:             Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                            int                2154                  1X
-//                          float                2155              1.001X
-//                         double                2179              1.011X
-//                         string                2179              1.011X
-Benchmark* BenchmarkLiterals() {
-  Benchmark* suite = new Benchmark("Literals");
-  BENCHMARK("int", "1");
-  BENCHMARK("float", "1.1f");
-  BENCHMARK("double", "1.1");
-  BENCHMARK("string", "'1.1'");
-  return suite;
-}
-
-// Arithmetic:           Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                        int-add               527.5                  1X
-//                     double-add                 528              1.001X
-Benchmark* BenchmarkArithmetic() {
-  Benchmark* suite = new Benchmark("Arithmetic");
-  BENCHMARK("int-add", "1 + 2");
-  BENCHMARK("double-add", "1.1 + 2.2");
-  return suite;
-}
-
-// Machine Info: Intel(R) Core(TM) i7-2600 CPU @ 3.40GHz
-// Like:                 Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                         equals               203.9                  1X
-//                     not equals               426.4              2.091X
-//                         strstr               142.8             0.7001X
-//                       strncmp1               269.7              1.323X
-//                       strncmp2               294.1              1.442X
-//                       strncmp3               775.7              3.804X
-//                          regex                19.7             0.0966X
-Benchmark* BenchmarkLike() {
-  Benchmark* suite = new Benchmark("Like");
-  BENCHMARK("equals", "'abcdefghijklmnopqrstuvwxyz' = 'abcdefghijklmnopqrstuvwxyz'");
-  BENCHMARK("not equals", "'abcdefghijklmnopqrstuvwxyz' = 'lmnopqrstuvwxyz'");
-  BENCHMARK("strstr", "'abcdefghijklmnopqrstuvwxyz' LIKE '%lmnopq%'");
-  BENCHMARK("strncmp1", "'abcdefghijklmnopqrstuvwxyz' LIKE '%xyz'");
-  BENCHMARK("strncmp2", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc%'");
-  BENCHMARK("strncmp3", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc'");
-  BENCHMARK("regex", "'abcdefghijklmnopqrstuvwxyz' LIKE 'abc%z'");
-  return suite;
-}
-
-// Cast:                 Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                     int_to_int                 824                  1X
-//                    int_to_bool                 878              1.066X
-//                  int_to_double               775.4              0.941X
-//                  int_to_string               32.47            0.03941X
-//              double_to_boolean               823.5             0.9994X
-//               double_to_bigint               775.4              0.941X
-//               double_to_string               4.682           0.005682X
-//                  string_to_int               402.6             0.4886X
-//                string_to_float               145.8             0.1769X
-//            string_to_timestamp               83.76             0.1017X
-Benchmark* BenchmarkCast() {
-  Benchmark* suite = new Benchmark("Cast");
-  BENCHMARK("int_to_int", "cast(1 as INT)");
-  BENCHMARK("int_to_bool", "cast(1 as BOOLEAN)");
-  BENCHMARK("int_to_double", "cast(1 as DOUBLE)");
-  BENCHMARK("int_to_string", "cast(1 as STRING)");
-  BENCHMARK("double_to_boolean", "cast(3.14 as BOOLEAN)");
-  BENCHMARK("double_to_bigint", "cast(3.14 as BIGINT)");
-  BENCHMARK("double_to_string", "cast(3.14 as STRING)");
-  BENCHMARK("string_to_int", "cast('1234' as INT)");
-  BENCHMARK("string_to_float", "cast('1234.5678' as FLOAT)");
-  BENCHMARK("string_to_timestamp", "cast('2011-10-22 09:10:11' as TIMESTAMP)");
-  return suite;
-}
-
-// ConditionalFunctions: Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                       not_null               877.8                  1X
-//                        is null               938.3              1.069X
-//                       compound               240.2             0.2736X
-//                    int_between                 191             0.2176X
-//              timestamp_between                18.5            0.02108X
-//                 string_between               93.94              0.107X
-//                        bool_in               356.6             0.4063X
-//                         int_in               209.7             0.2389X
-//                       float_in               216.4             0.2465X
-//                      string_in               120.1             0.1368X
-//                   timestamp_in               19.79            0.02255X
-//                         if_int               506.8             0.5773X
-//                      if_string               470.6             0.5361X
-//                   if_timestamp               70.19            0.07996X
-//                  coalesce_bool               194.2             0.2213X
-//                       case_int                 259             0.2951X
-Benchmark* BenchmarkConditionalFunctions() {
-// TODO: expand these cases when the parser issues are fixed (see corresponding tests
-// in expr-test).
-  Benchmark* suite = new Benchmark("ConditionalFunctions");
-  BENCHMARK("not_null", "!NULL");
-  BENCHMARK("is null", "5 IS NOT NULL");
-  BENCHMARK("compound", "(TRUE && TRUE) || FALSE");
-  BENCHMARK("int_between", "5 between 5 and 6");
-  BENCHMARK("timestamp_between", "cast('2011-10-22 09:10:11' as timestamp) between "
-      "cast('2011-09-22 09:10:11' as timestamp) and "
-      "cast('2011-12-22 09:10:11' as timestamp)");
-  BENCHMARK("string_between", "'abc' between 'aaa' and 'aab'");
-  BENCHMARK("bool_in", "true in (true, false, false)");
-  BENCHMARK("int_in", "1 in (2, 3, 1)");
-  BENCHMARK("float_in","1.1 not in (2, 3, 4.5)");
-  BENCHMARK("string_in", "'ab' in ('cd', 'efg', 'ab', 'h')");
-  BENCHMARK("timestamp_in", "cast('2011-11-23' as timestamp) "
-        "in (cast('2011-11-22 09:10:11' as timestamp), "
-        "cast('2011-11-23 09:11:12' as timestamp), "
-        "cast('2011-11-24 09:12:13' as timestamp))");
-  BENCHMARK("if_int", "if(TRUE, 10, 20)");
-  BENCHMARK("if_string", "if(TRUE, 'abc', 'defgh')");
-  BENCHMARK("if_timestamp", "if(TRUE, cast('2011-01-01 09:01:01' as timestamp), "
-      "cast('1999-06-14 19:07:25' as timestamp))");
-  BENCHMARK("coalesce_bool", "coalesce(if(true, NULL, NULL), if(true, NULL, NULL))");
-  BENCHMARK("case_int", "case 21 when 20 then 1 when 19 then 2 when 21 then 3 end");
-  return suite;
-}
-
-// StringFunctions:      Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                         length               920.2                  1X
-//                     substring1               351.4             0.3819X
-//                     substring2               327.9             0.3563X
-//                           left               508.6             0.5527X
-//                          right               508.2             0.5522X
-//                          lower               103.9             0.1129X
-//                          upper               103.2             0.1121X
-//                        reverse               324.9             0.3531X
-//                           trim               421.2             0.4578X
-//                          ltrim               526.6             0.5723X
-//                          rtrim               566.5             0.6156X
-//                          space               94.63             0.1028X
-//                          ascii                1048              1.139X
-//                          instr               175.6             0.1909X
-//                         locate               184.7             0.2007X
-//                        locate2               175.8             0.1911X
-//                         concat               109.5              0.119X
-//                        concat2               75.83            0.08241X
-//                       concatws               143.4             0.1559X
-//                      concatws2               70.38            0.07649X
-//                         repeat               98.54             0.1071X
-//                           lpad               154.7             0.1681X
-//                           rpad               145.6             0.1582X
-//                    find_in_set               83.38            0.09061X
-//                 regexp_extract                6.42           0.006977X
-//                 regexp_replace              0.7435           0.000808X
-Benchmark* BenchmarkStringFunctions() {
-  Benchmark* suite = new Benchmark("StringFunctions");
-  BENCHMARK("length", "length('Hello World!')");
-  BENCHMARK("substring1", "substring('Hello World!', 5)");
-  BENCHMARK("substring2", "substring('Hello World!', 5, 5)");
-  BENCHMARK("left", "strleft('Hello World!', 7)");
-  BENCHMARK("right", "strleft('Hello World!', 7)");
-  BENCHMARK("lower", "lower('Hello World!')");
-  BENCHMARK("upper", "upper('Hello World!')");
-  BENCHMARK("reverse", "reverse('Hello World!')");
-  BENCHMARK("trim", "trim('  Hello World!  ')");
-  BENCHMARK("ltrim", "ltrim('  Hello World!  ')");
-  BENCHMARK("rtrim", "rtrim('  Hello World!  ')");
-  BENCHMARK("space", "space(7)");
-  BENCHMARK("ascii", "ascii('abcd')");
-  BENCHMARK("instr", "instr('xyzabc', 'abc')");
-  BENCHMARK("locate", "locate('abc', 'xyzabc')");
-  BENCHMARK("locate2", "locate('abc', 'abcxyzabc', 3)");
-  BENCHMARK("concat", "concat('a', 'bcd')");
-  BENCHMARK("concat2", "concat('a', 'bb', 'ccc', 'dddd')");
-  BENCHMARK("concatws", "concat_ws('a', 'b')");
-  BENCHMARK("concatws2", "concat_ws('a', 'b', 'c', 'd')");
-  BENCHMARK("repeat", "repeat('abc', 7)");
-  BENCHMARK("lpad", "lpad('abc', 7, 'xyz')");
-  BENCHMARK("rpad", "rpad('abc', 7, 'xyz')");
-  BENCHMARK("find_in_set", "find_in_set('ab', 'abc,ad,ab,ade,cde')");
-  BENCHMARK("regexp_extract", "regexp_extract('abxcy1234a', 'a.x.y.*a', 0)");
-  BENCHMARK("regexp_replace", "regexp_replace('axcaycazc', '', 'r')");
-  return suite;
-}
-
-// UrlFunctions:         Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                      authority               118.1                  1X
-//                           file               95.52              0.809X
-//                           host               94.52             0.8005X
-//                           path               98.63             0.8353X
-//                       protocol               36.29             0.3073X
-//                           user               121.1              1.026X
-//                      user_info               121.4              1.029X
-//                     query_name               41.34             0.3501X
-Benchmark* BenchmarkUrlFunctions() {
-  Benchmark* suite = new Benchmark("UrlFunctions");
-  BENCHMARK("authority", "parse_url('http://user:pass@example.com:80/docs/books/tutorial/"
-      "index.html?name=networking#DOWNLOADING', 'AUTHORITY')");
-  BENCHMARK("file", "parse_url('http://example.com/docs/books/tutorial/"
-      "index.html?name=networking   ', 'FILE')");
-  BENCHMARK("host", "parse_url('http://example.com:80/docs/books/tutorial/"
-      "index.html?name=networking#DOWNLOADING', 'HOST')");
-  BENCHMARK("path", "parse_url('http://user:pass@example.com/docs/books/tutorial/"
-      "index.html?name=networking#DOWNLOADING', 'PATH')");
-  BENCHMARK("protocol", "parse_url('user:pass@example.com/docs/books/tutorial/"
-      "index.html?name=networking#DOWNLOADING', 'PROTOCOL')");
-  BENCHMARK("user", "parse_url('http://user@example.com/docs/books/tutorial/"
-        "index.html?name=networking#DOWNLOADING', 'USERINFO')");
-  BENCHMARK("user_info", "parse_url('http://user:pass@example.com:80/docs/books/tutorial/"
-      "index.html?name=networking#DOWNLOADING', 'USERINFO')");
-  BENCHMARK("query_name", "parse_url('http://example.com:80/docs/books/tutorial/"
-      "index.htmltest=true&name=networking&op=true', 'QUERY', 'name')");
-  return suite;
-}
-
-// MathFunctions:        Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                             pi                1642                  1X
-//                              e                1546             0.9416X
-//                            abs                 877             0.5342X
-//                             ln               110.7            0.06744X
-//                          log10               88.48             0.0539X
-//                           log2               108.3            0.06597X
-//                            log               55.61            0.03387X
-//                            pow               53.93            0.03285X
-//                           sqrt               629.6             0.3835X
-//                           sign                 732             0.4459X
-//                            sin               176.3             0.1074X
-//                           asin               169.6             0.1033X
-//                            cos               156.3             0.0952X
-//                           acos               167.5              0.102X
-//                            tan               176.3             0.1074X
-//                           atan               153.8            0.09371X
-//                        radians               601.5             0.3664X
-//                        degrees               601.5             0.3664X
-//                            bin                  45            0.02741X
-//                       pmod_int               147.3            0.08976X
-//                     pmod_float               172.9             0.1053X
-//                       positive                 877             0.5342X
-//                       negative               936.9             0.5707X
-//                           ceil               466.7             0.2843X
-//                          floor               390.9             0.2381X
-//                          round               820.5             0.4998X
-//                         round2               220.2             0.1341X
-//                        hex_int               5.745             0.0035X
-//                     hex_string               4.441           0.002705X
-//                          unhex               3.394           0.002067X
-//                       conv_int               33.15            0.02019X
-//                    conv_string                36.6            0.02229X
-Benchmark* BenchmarkMathFunctions() {
-  Benchmark* suite = new Benchmark("MathFunctions");
-  BENCHMARK("pi", "pi()");
-  BENCHMARK("e", "e()");
-  BENCHMARK("abs", "abs(-1.0)");
-  BENCHMARK("ln", "ln(3.14)");
-  BENCHMARK("log10", "log10(3.14)");
-  BENCHMARK("log2", "log2(3.14)");
-  BENCHMARK("log", "log(3.14, 5)");
-  BENCHMARK("pow", "pow(3.14, 5)");
-  BENCHMARK("sqrt", "sqrt(3.14)");
-  BENCHMARK("sign", "sign(1.0)");
-  BENCHMARK("sin", "sin(3.14)");
-  BENCHMARK("asin", "asin(3.14)");
-  BENCHMARK("cos", "cos(3.14)");
-  BENCHMARK("acos", "acos(3.14)");
-  BENCHMARK("tan", "tan(3.14)");
-  BENCHMARK("atan", "atan(3.14)");
-  BENCHMARK("radians", "radians(3.14)");
-  BENCHMARK("degrees", "degrees(3.14)");
-  BENCHMARK("bin", "bin(12345)");
-  BENCHMARK("pmod_int", "pmod(12345, 12)");
-  BENCHMARK("pmod_float", "pmod(12345.678, 12.34)");
-  BENCHMARK("positive", "positive(12345)");
-  BENCHMARK("negative", "negative(12345)");
-  BENCHMARK("ceil", "ceil(-10.05)");
-  BENCHMARK("floor", "floor(-10.05)");
-  BENCHMARK("round", "round(-10.05)");
-  BENCHMARK("round2", "round(-10.056789, 4)");
-  BENCHMARK("hex_int", "hex(16)");
-  BENCHMARK("hex_string", "hex('impala')");
-  BENCHMARK("unhex", "hex('496D70616C61')");
-  BENCHMARK("conv_int", "conv(100101, 2, 36)");
-  BENCHMARK("conv_string", "conv('100101', 2, 36)");
-  return suite;
-}
-
-// TimestampFunctions:   Function                Rate          Comparison
-// ----------------------------------------------------------------------
-//                        literal               68.18                  1X
-//                      to_string               1.131            0.01659X
-//                       add_year               34.57              0.507X
-//                      sub_month               33.04             0.4846X
-//                      add_weeks               56.15             0.8236X
-//                       sub_days               57.21             0.8391X
-//                            add               55.85             0.8191X
-//                      sub_hours               44.44             0.6519X
-//                    add_minutes               43.96             0.6448X
-//                    sub_seconds               42.78             0.6274X
-//                      add_milli               43.43             0.6371X
-//                      sub_micro               43.88             0.6436X
-//                       add_nano               41.83             0.6135X
-//                unix_timestamp1               32.74             0.4803X
-//                unix_timestamp2               39.39             0.5778X
-//                     from_unix1               1.192            0.01748X
-//                     from_unix2               1.602             0.0235X
-//                           year                73.4              1.077X
-//                          month               72.53              1.064X
-//                   day of month               71.98              1.056X
-//                    day of year               56.67             0.8312X
-//                   week of year               50.68             0.7433X
-//                           hour               100.1              1.468X
-//                         minute               97.18              1.425X
-//                         second                96.7              1.418X
-//                        to date               3.075            0.04511X
-//                      date diff               39.54             0.5799X
-Benchmark* BenchmarkTimestampFunctions() {
-  Benchmark* suite = new Benchmark("TimestampFunctions");
-  BENCHMARK("literal", "cast('2012-01-01 09:10:11.123456789' as timestamp)");
-  BENCHMARK("to_string",
-      "cast(cast('2012-01-01 09:10:11.123456789' as timestamp) as string)");
-  BENCHMARK("add_year", "date_add(cast('2012-01-01 09:10:11.123456789' "
-      "as timestamp), interval 10 years)");
-  BENCHMARK("sub_month", "date_sub(cast('2012-02-29 09:10:11.123456789' "
-      "as timestamp), interval 1 month)");
-  BENCHMARK("add_weeks", "date_add(cast('2012-01-01 09:10:11.123456789' "
-      "as timestamp), interval 53 weeks)");
-  BENCHMARK("sub_days", "date_sub(cast('2011-12-22 09:10:11.12345678' "
-      "as timestamp), interval 365 days)");
-  BENCHMARK("add", "date_add(cast('2012-01-01 09:10:11.123456789' "
-      "as timestamp), 10)");
-  BENCHMARK("sub_hours", "date_sub(cast('2012-01-02 01:00:00.123456789' "
-      "as timestamp), interval 25 hours)");
-  BENCHMARK("add_minutes", "date_add(cast('2012-01-01 00:00:00.123456789' "
-      "as timestamp), interval 1533 minutes)");
-  BENCHMARK("sub_seconds", "date_sub(cast('2012-01-02 01:00:33.123456789' "
-      "as timestamp), interval 90033 seconds)");
-  BENCHMARK("add_milli", "date_add(cast('2012-01-01 00:00:00.000000001' "
-      "as timestamp), interval 90000033 milliseconds)");
-  BENCHMARK("sub_micro", "date_sub(cast('2012-01-01 00:00:00.001033001' "
-      "as timestamp), interval 1033 microseconds)");
-  BENCHMARK("add_nano", "date_add(cast('2012-01-01 00:00:00.000000001' "
-      "as timestamp), interval 1033 nanoseconds)");
-  BENCHMARK("unix_timestamp1",
-      "unix_timestamp('1970-01-01 00:00:00', 'yyyy-MM-dd HH:mm:ss')");
-  BENCHMARK("unix_timestamp2",
-      "unix_timestamp('1970-10-01', 'yyyy-MM-dd')");
-  BENCHMARK("from_unix1", "from_unixtime(0, 'yyyy-MM-dd HH:mm:ss')");
-  BENCHMARK("from_unix2", "from_unixtime(0, 'yyyy-MM-dd')");
-  BENCHMARK("year", "year(cast('2011-12-22' as timestamp))");
-  BENCHMARK("month", "month(cast('2011-12-22' as timestamp))");
-  BENCHMARK("day of month", "dayofmonth(cast('2011-12-22' as timestamp))");
-  BENCHMARK("day of year", "dayofyear(cast('2011-12-22' as timestamp))");
-  BENCHMARK("week of year", "weekofyear(cast('2011-12-22' as timestamp))");
-  BENCHMARK("hour", "hour(cast('09:10:11.000000' as timestamp))");
-  BENCHMARK("minute", "minute(cast('09:10:11.000000' as timestamp))");
-  BENCHMARK("second", "second(cast('09:10:11.000000' as timestamp))");
-  BENCHMARK("to date",
-      "to_date(cast('2011-12-22 09:10:11.12345678' as timestamp))");
-  BENCHMARK("date diff", "datediff(cast('2011-12-22 09:10:11.12345678' as timestamp), "
-      "cast('2012-12-22' as timestamp))");
-#if 0
-  // TODO: need to create a valid runtime state for these functions
-  BENCHMARK("from utc",
-      "from_utc_timestamp(cast(1.3041352164485E9 as timestamp), 'PST')");
-  BENCHMARK("to utc",
-      "to_utc_timestamp(cast('2011-01-01 01:01:01' as timestamp), 'PST')");
-  BENCHMARK("now", "now()");
-  BENCHMARK("unix_timestamp", "unix_timestamp()");
-#endif
-  return suite;
-}
-
-int main(int argc, char** argv) {
-  CpuInfo::Init();
-
-  // Generate all the tests first (this does the planning)
-  Benchmark* literals = BenchmarkLiterals();
-  Benchmark* arithmetics = BenchmarkArithmetic();
-  Benchmark* like = BenchmarkLike();
-  Benchmark* cast = BenchmarkCast();
-  Benchmark* conditional_fns = BenchmarkConditionalFunctions();
-  Benchmark* string_fns = BenchmarkStringFunctions();
-  Benchmark* url_fns = BenchmarkUrlFunctions();
-  Benchmark* math_fns = BenchmarkMathFunctions();
-  Benchmark* timestamp_fns = BenchmarkTimestampFunctions();
-
-  cout << Benchmark::GetMachineInfo() << endl;
-  cout << literals->Measure() << endl;
-  cout << arithmetics->Measure() << endl;
-  cout << like->Measure() << endl;
-  cout << cast->Measure() << endl;
-  cout << conditional_fns->Measure() << endl;
-  cout << string_fns->Measure() << endl;
-  cout << url_fns->Measure() << endl;
-  cout << math_fns->Measure() << endl;
-  cout << timestamp_fns->Measure() << endl;
-
-  return 0;
-}


Mime
View raw message