Read the entire file into memory in one go to measure bandwidth.
| 207 | |
| 208 | /// Read the entire file into memory in one go to measure bandwidth. |
| 209 | static 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 | |
| 227 | constexpr int64_t kChunkSize = 5 * 1024 * 1024; |
| 228 |
no test coverage detected