westonpace commented on a change in pull request #12755:
URL: https://github.com/apache/arrow/pull/12755#discussion_r838761964



##########
File path: cpp/src/arrow/compute/exec/expression_execution_benchmark.cc
##########
@@ -0,0 +1,56 @@
+// 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.
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/cast.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+auto expression =
+    and_(less(field_ref("x"), literal(20)), greater(field_ref("x"), 
literal(0)));
+
+static void Execution(benchmark::State& state) {
+  const auto array_batches = static_cast<int32_t>(state.range(0));
+  const auto array_size = 10000000 / array_batches;
+
+  ExecContext ctx;
+  auto dataset_schema = schema({
+      field("x", int64()),
+  });
+  ExecBatch input({Datum(ConstantArrayGenerator::Int64(array_size, 5))},
+                  /*length=*/1);
+
+  ASSIGN_OR_ABORT(auto bound, expression.Bind(*dataset_schema));
+  for (auto _ : state) {
+    for (int it = 0; it < array_batches; ++it)
+      ABORT_NOT_OK(ExecuteScalarExpression(bound, input, &ctx).status());
+  }
+  state.SetBytesProcessed(state.iterations() * 8 * array_size);

Review comment:
       They are directly related and yes, interchangeable, but I think I agree 
with @pitrou that items/second is probably more likely to be all we need.  It 
also makes it clearer to the reader what is being tested.  The code we are 
testing here (kernel dispatch) never actually operates on the arrays 
themselves.  It is only responsible for passing the arrays to the appropriate 
kernels.  So the size (or byte width) of the array shouldn't matter too much.
   
   The kernel benchmarks themselves are a different story.  And you will notice 
that in `compare_benchmark.cc` for example we test the kernel on a wide variety 
of data types.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: github-unsubscr...@arrow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to