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



##########
File path: cpp/src/arrow/csv/reader_benchmark.cc
##########
@@ -0,0 +1,139 @@
+// 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 <string>
+
+#include "arrow/buffer.h"
+#include "arrow/csv/options.h"
+#include "arrow/csv/reader.h"
+#include "arrow/csv/test_common.h"
+#include "arrow/io/interfaces.h"
+#include "arrow/io/memory.h"
+#include "arrow/testing/gtest_util.h"
+#include "arrow/util/thread_pool.h"
+
+namespace arrow {
+namespace csv {
+
+class SlowInputStream : public io::InputStream {
+ public:
+  explicit SlowInputStream(std::shared_ptr<io::BufferReader> target, int64_t 
latency_ms)
+      : target_(std::move(target)) {
+    latency_s_ = static_cast<double>(latency_ms) / 1000.0;
+  }
+  virtual ~SlowInputStream() {}
+
+  Result<util::string_view> Peek(int64_t nbytes) override {
+    return target_->Peek(nbytes);
+  }
+  bool supports_zero_copy() const override { return 
target_->supports_zero_copy(); }
+  Status Close() override { return target_->Close(); }
+  Status Abort() override { return target_->Abort(); }
+  Result<int64_t> Tell() const override { return target_->Tell(); }
+  bool closed() const override { return target_->closed(); }
+  Result<int64_t> Read(int64_t nbytes, void* out) override {
+    if (latency_s_ > 0) {
+      SleepFor(latency_s_);
+    }
+    return target_->Read(nbytes, out);
+  }
+  Result<std::shared_ptr<Buffer>> Read(int64_t nbytes) override {
+    if (latency_s_ > 0) {
+      SleepFor(latency_s_);
+    }
+    return target_->Read(nbytes);
+  }
+  Status Seek(int64_t pos) { return target_->Seek(pos); }
+
+ private:
+  std::shared_ptr<io::BufferReader> target_;
+  double latency_s_;
+};
+
+static ReadOptions CreateReadOptions(bool use_threads, bool use_async) {
+  auto result = csv::ReadOptions::Defaults();
+  result.use_threads = use_threads;
+  result.legacy_blocking_reads = !use_async;
+  // Simulate larger files by using smaller block files so the impact of 
multiple
+  // blocks is seen but we don't have to spend the time waiting on the large 
I/O

Review comment:
       I've removed this benchmark from the PR.  Those fixed costs is what I 
was hoping to emphasize since I was looking for to see how much overhead the 
futures implementation was adding and wanted to minimize the reading/parsing 
costs (since this PR didn't change those functions at all).




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

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


Reply via email to