jorisvandenbossche commented on code in PR #40358:
URL: https://github.com/apache/arrow/pull/40358#discussion_r1535512580


##########
cpp/src/arrow/tensor_benchmark.cc:
##########
@@ -0,0 +1,67 @@
+// 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/record_batch.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/testing/random.h"
+#include "arrow/type.h"
+#include "arrow/util/benchmark_util.h"
+
+namespace arrow {
+
+template <typename ValueType>
+static void BatchToTensorSimple(benchmark::State& state) {
+  using CType = typename ValueType::c_type;
+  std::shared_ptr<DataType> ty = TypeTraits<ValueType>::type_singleton();
+
+  const int64_t kNumRows = state.range(0) / sizeof(CType);

Review Comment:
   ```suggestion
     const int64_t num_cols = state.range(1);
     const int64_t num_rows = state.range(0) / num_cols / sizeof(CType);
   ```
   
   To get the number of rows, I would divide the total size by the number of 
columns as well, so the total size (and timing) for each benchmark is more or 
less the same (right now the case with 3 columns is really small time, while 
the one with 300 columns probably takes a bit long).
   
   And I think we can also use normal variable names here, the `k` prefix is 
for global constants, but here I would say it's just a local variable.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to