pitrou commented on code in PR #15101:
URL: https://github.com/apache/arrow/pull/15101#discussion_r1060475679


##########
cpp/src/parquet/arrow/reader_writer_benchmark.cc:
##########
@@ -197,6 +197,52 @@ BENCHMARK_TEMPLATE2(BM_WriteColumn, true, DoubleType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, false, BooleanType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, true, BooleanType);
 
+int32_t kInfiniteUniqueValues = -1;
+
+std::shared_ptr<::arrow::Table> RandomStringTable(int64_t length, int64_t 
unique_values,
+                                                  int64_t null_percentage) {
+  std::shared_ptr<::arrow::DataType> type = ::arrow::utf8();
+  std::shared_ptr<::arrow::Array> arr;
+  ::arrow::random::RandomArrayGenerator generator(500);

Review Comment:
   Is this the seed?



##########
cpp/src/parquet/arrow/reader_writer_benchmark.cc:
##########
@@ -197,6 +197,52 @@ BENCHMARK_TEMPLATE2(BM_WriteColumn, true, DoubleType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, false, BooleanType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, true, BooleanType);
 
+int32_t kInfiniteUniqueValues = -1;
+
+std::shared_ptr<::arrow::Table> RandomStringTable(int64_t length, int64_t 
unique_values,
+                                                  int64_t null_percentage) {
+  std::shared_ptr<::arrow::DataType> type = ::arrow::utf8();
+  std::shared_ptr<::arrow::Array> arr;
+  ::arrow::random::RandomArrayGenerator generator(500);
+  double null_probability = static_cast<double>(null_percentage) / 100.0;
+  if (unique_values == kInfiniteUniqueValues) {
+    arr = generator.String(length, /*min_length=*/3, /*max_length=*/32,
+                           /*null_probability=*/null_probability);
+  } else {
+    arr = generator.StringWithRepeats(length, /*unique=*/unique_values,
+                                      /*min_length=*/3, /*max_length=*/32,
+                                      /*null_probability=*/null_probability);
+  }
+  return ::arrow::Table::Make(
+      ::arrow::schema({::arrow::field("column", type, null_percentage > 0)}), 
{arr});
+}
+
+static void BM_WriteBinaryColumn(::benchmark::State& state) {
+  std::shared_ptr<::arrow::Table> table =
+      RandomStringTable(BENCHMARK_SIZE, state.range(1), state.range(0));
+
+  while (state.KeepRunning()) {
+    auto output = CreateOutputStream();
+    EXIT_NOT_OK(
+        WriteTable(*table, ::arrow::default_memory_pool(), output, 
BENCHMARK_SIZE));
+  }
+
+  int64_t total_bytes = table->column(0)->chunk(0)->data()->buffers[1]->size();
+  state.SetItemsProcessed(BENCHMARK_SIZE * state.iterations());
+  state.SetBytesProcessed(total_bytes * state.iterations());
+}
+
+BENCHMARK(BM_WriteBinaryColumn)
+    ->Args({/*null_probability*/ 0, /*unique_values*/ 2})
+    ->Args({/*null_probability*/ 0, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 0, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 1, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 50, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 99, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 1, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 50, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 99, /*unique_values*/ kInfiniteUniqueValues});

Review Comment:
   Can you use `ArgNames` to make the arguments more descriptive in the output?



##########
cpp/src/parquet/arrow/reader_writer_benchmark.cc:
##########
@@ -197,6 +197,52 @@ BENCHMARK_TEMPLATE2(BM_WriteColumn, true, DoubleType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, false, BooleanType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, true, BooleanType);
 
+int32_t kInfiniteUniqueValues = -1;
+
+std::shared_ptr<::arrow::Table> RandomStringTable(int64_t length, int64_t 
unique_values,
+                                                  int64_t null_percentage) {
+  std::shared_ptr<::arrow::DataType> type = ::arrow::utf8();
+  std::shared_ptr<::arrow::Array> arr;
+  ::arrow::random::RandomArrayGenerator generator(500);
+  double null_probability = static_cast<double>(null_percentage) / 100.0;
+  if (unique_values == kInfiniteUniqueValues) {
+    arr = generator.String(length, /*min_length=*/3, /*max_length=*/32,
+                           /*null_probability=*/null_probability);
+  } else {
+    arr = generator.StringWithRepeats(length, /*unique=*/unique_values,
+                                      /*min_length=*/3, /*max_length=*/32,
+                                      /*null_probability=*/null_probability);
+  }
+  return ::arrow::Table::Make(
+      ::arrow::schema({::arrow::field("column", type, null_percentage > 0)}), 
{arr});
+}
+
+static void BM_WriteBinaryColumn(::benchmark::State& state) {

Review Comment:
   Does it use the PLAIN encoding? Add a comment?



##########
cpp/src/parquet/arrow/reader_writer_benchmark.cc:
##########
@@ -197,6 +197,52 @@ BENCHMARK_TEMPLATE2(BM_WriteColumn, true, DoubleType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, false, BooleanType);
 BENCHMARK_TEMPLATE2(BM_WriteColumn, true, BooleanType);
 
+int32_t kInfiniteUniqueValues = -1;
+
+std::shared_ptr<::arrow::Table> RandomStringTable(int64_t length, int64_t 
unique_values,
+                                                  int64_t null_percentage) {
+  std::shared_ptr<::arrow::DataType> type = ::arrow::utf8();
+  std::shared_ptr<::arrow::Array> arr;
+  ::arrow::random::RandomArrayGenerator generator(500);
+  double null_probability = static_cast<double>(null_percentage) / 100.0;
+  if (unique_values == kInfiniteUniqueValues) {
+    arr = generator.String(length, /*min_length=*/3, /*max_length=*/32,
+                           /*null_probability=*/null_probability);
+  } else {
+    arr = generator.StringWithRepeats(length, /*unique=*/unique_values,
+                                      /*min_length=*/3, /*max_length=*/32,
+                                      /*null_probability=*/null_probability);

Review Comment:
   Do we expect duplicate values to show different performance characteristics? 
Otherwise, the `unique_values` argument may not be very useful.



##########
cpp/src/parquet/arrow/reader_writer_benchmark.cc:
##########
@@ -319,6 +365,29 @@ BENCHMARK_TEMPLATE2(BM_ReadColumn, true, BooleanType)
     ->Args({kAlternatingOrNa, 1})
     ->Args({5, 10});
 
+//
+// Benchmark reading binary column
+//
+
+static void BM_ReadBinaryColumn(::benchmark::State& state) {
+  std::shared_ptr<::arrow::Table> table =
+      RandomStringTable(BENCHMARK_SIZE, state.range(1), state.range(0));
+
+  int64_t total_bytes = table->column(0)->chunk(0)->data()->buffers[1]->size();
+  BenchmarkReadTable(state, *table, table->num_rows(), total_bytes);
+}
+
+BENCHMARK(BM_ReadBinaryColumn)
+    ->Args({/*null_probability*/ 0, /*unique_values*/ 2})
+    ->Args({/*null_probability*/ 0, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 0, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 1, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 50, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 99, /*unique_values*/ 32})
+    ->Args({/*null_probability*/ 1, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 50, /*unique_values*/ kInfiniteUniqueValues})
+    ->Args({/*null_probability*/ 99, /*unique_values*/ kInfiniteUniqueValues});

Review Comment:
   Similar questions and comments here.



-- 
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