You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2022/07/02 00:55:17 UTC

[GitHub] [arrow] vibhatha commented on a diff in pull request #13426: [DRAFT] ARROW-16894: [C++] Add Benchmarks for Asof Join Node

vibhatha commented on code in PR #13426:
URL: https://github.com/apache/arrow/pull/13426#discussion_r912299882


##########
cpp/src/arrow/compute/exec/asof_join_benchmark.cc:
##########
@@ -0,0 +1,1023 @@
+// 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 <stdio.h>
+#include <stdlib.h>
+#include <condition_variable>
+#include <mutex>
+#include <string>
+
+#include "benchmark/benchmark.h"
+
+#include "arrow/compute/cast.h"
+#include "arrow/compute/exec.h"
+#include "arrow/compute/exec/expression.h"
+#include "arrow/compute/exec/options.h"
+#include "arrow/compute/exec/task_util.h"
+#include "arrow/compute/exec/test_util.h"
+#include "arrow/dataset/partition.h"
+#include "arrow/filesystem/api.h"
+#include "arrow/ipc/api.h"
+#include "arrow/testing/future_util.h"
+#include "arrow/testing/generator.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/type.h"
+
+namespace arrow {
+namespace compute {
+
+static const char* time_col = "time";
+static const char* key_col = "id";
+static bool createdBenchmarkFiles = false;
+
+// requires export PYTHONPATH=/path/to/bamboo-streaming
+// calls generate_benchmark_files to create tables (feather files) varying in frequency,
+// width, key density for benchmarks. places generated files in benchmark/data. This
+// operation runs once at the beginning of benchmarking.
+static void DoSetup() {
+  if (!createdBenchmarkFiles) {
+    system(
+        "mkdir benchmark_data/ && python3 "
+        "~/summer/bamboo-streaming/bamboo/generate_benchmark_files.py");
+    createdBenchmarkFiles = true;
+  }
+}
+
+static void DoTeardown() { system("rm -rf benchmark_data/"); }
+
+static std::vector<std::string> generateRightHandTables(std::string freq, int width_index,
+                                                        int num_tables,
+                                                        int num_ids_index) {
+  auto const generate_file_name = [](std::string freq, std::string is_wide,
+                                     std::string num_ids, std::string num) {
+    return freq + "_" + is_wide + "_" + num_ids + num + ".feather";
+  };
+
+  std::string width_table[] = {"1_cols",  "10_cols", "20_cols",
+                               "40_cols", "80_cols", "100_cols"};   // 0 - 5
+  std::string num_ids_table[] = {"100_ids", "2000_ids", "5k_ids"};  // 0 - 2
+
+  std::string wide_string = width_table[width_index];
+  std::string ids = num_ids_table[num_ids_index];
+
+  std::vector<std::string> right_hand_tables;
+  for (int j = 1; j <= num_tables; j++) {
+    right_hand_tables.push_back(
+        generate_file_name(freq, wide_string, ids, std::to_string(j)));
+  }

Review Comment:
   May be? 
   
   ```suggestion
     std::vector<std::string> right_hand_tables;
     right_hand_tables.reserve(num_tables);
     
     for (int j = 1; j <= num_tables; j++) {
       right_hand_tables.push_back(
           generate_file_name(freq, width_table[width_index], num_ids_table[num_ids_index],
             std::to_string(j)));
     }
   ```



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