MCPcopy Create free account
hub / github.com/apache/arrow / NaiveRead

Function NaiveRead

cpp/src/arrow/filesystem/s3fs_benchmark.cc:209–225  ·  view source on GitHub ↗

Read the entire file into memory in one go to measure bandwidth.

Source from the content-addressed store, hash-verified

207
208/// Read the entire file into memory in one go to measure bandwidth.
209static void NaiveRead(benchmark::State& st, S3FileSystem* fs, const std::string& path) {
210 int64_t total_bytes = 0;
211 int total_items = 0;
212 for (auto _ : st) {
213 std::shared_ptr<io::RandomAccessFile> file;
214 std::shared_ptr<Buffer> buf;
215 int64_t size;
216 ASSERT_OK_AND_ASSIGN(file, fs->OpenInputFile(path));
217 ASSERT_OK_AND_ASSIGN(size, file->GetSize());
218 ASSERT_OK_AND_ASSIGN(buf, file->ReadAt(0, size));
219 total_bytes += buf->size();
220 total_items += 1;
221 }
222 st.SetBytesProcessed(total_bytes);
223 st.SetItemsProcessed(total_items);
224 std::cerr << "Read the file " << total_items << " times" << std::endl;
225}
226
227constexpr int64_t kChunkSize = 5 * 1024 * 1024;
228

Calls 5

ASSERT_OK_AND_ASSIGNFunction · 0.70
OpenInputFileMethod · 0.45
GetSizeMethod · 0.45
ReadAtMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected