You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "felipecrv (via GitHub)" <gi...@apache.org> on 2023/03/31 19:20:03 UTC

[GitHub] [arrow] felipecrv commented on a diff in pull request #34811: GH-14937: [C++] String Sort / Rank Benchmarks

felipecrv commented on code in PR #34811:
URL: https://github.com/apache/arrow/pull/34811#discussion_r1154814746


##########
cpp/src/arrow/compute/kernels/vector_sort_benchmark.cc:
##########
@@ -99,6 +99,40 @@ static void ChunkedArraySortFuncInt64Benchmark(benchmark::State& state,
   ArraySortFuncBenchmark(state, runner, std::make_shared<ChunkedArray>(chunks));
 }
 
+template <typename Runner>
+static void ChunkedArraySortFuncStringBenchmark(benchmark::State& state,
+                                                const Runner& runner, int32_t min_length,
+                                                int32_t max_length) {
+  RegressionArgs args(state);
+
+  // The array_size is derived from these two equations:
+  //
+  //     size = array_size * (1.0 - args.null_proportion) * string_mean_length
+  //     string_mean_length = (max_length + min_length) / 2.0
+  const double valid_proportion = 1.0 - args.null_proportion;
+  const double array_size =
+      (valid_proportion > std::numeric_limits<double>::epsilon())
+          ? (args.size * 2) / (valid_proportion * (max_length + min_length))
+          : (args.size * 2) / (max_length + min_length);
+
+  const auto n_chunks = 10;
+  const auto array_chunk_size = static_cast<int64_t>(std::round(array_size / n_chunks));
+  auto rand = random::RandomArrayGenerator(kSeed);
+
+  ArrayVector chunks;
+  int64_t generated_array_size_in_bytes = 0;
+  for (auto i = 0; i < n_chunks; ++i) {
+    auto values =
+        rand.String(array_chunk_size, min_length, max_length, args.null_proportion);
+    auto array = arrow::internal::checked_pointer_cast<const arrow::StringArray>(values);
+    generated_array_size_in_bytes += array->value_data()->size();
+    chunks.push_back(std::move(values));
+  }
+
+  state.counters["generated_array_size"] = generated_array_size_in_bytes;

Review Comment:
   I accidentally pushed the commit that adds it here. I only wanted it temporarily to double-check my estimation formula.



-- 
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-unsubscribe@arrow.apache.org

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