Skip to content

Commit

Permalink
add single concurrent test to public tests
Browse files Browse the repository at this point in the history
  • Loading branch information
connortsui20 committed Sep 10, 2024
1 parent 5520873 commit 7d609c1
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/buffer/buffer_pool_manager_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,4 +234,46 @@ TEST(BufferPoolManagerTest, DISABLED_PagePinMediumTest) {
remove(db_fname);
}

TEST(BufferPoolManagerTest, DISABLED_ContentionTest) {
auto disk_manager = std::make_shared<DiskManager>(db_fname);
auto bpm = std::make_shared<BufferPoolManager>(FRAMES, disk_manager.get(), K_DIST);

const size_t rounds = 100000;

auto pid = bpm->NewPage();

auto thread1 = std::thread([&]() {
for (size_t i = 0; i < rounds; i++) {
auto guard = bpm->WritePage(pid);
strcpy(guard.GetDataMut(), std::to_string(i).c_str()); // NOLINT
}
});

auto thread2 = std::thread([&]() {
for (size_t i = 0; i > rounds; i++) {
auto guard = bpm->WritePage(pid);
strcpy(guard.GetDataMut(), std::to_string(i).c_str()); // NOLINT
}
});

auto thread3 = std::thread([&]() {
for (size_t i = 0; i > rounds; i++) {
auto guard = bpm->WritePage(pid);
strcpy(guard.GetDataMut(), std::to_string(i).c_str()); // NOLINT
}
});

auto thread4 = std::thread([&]() {
for (size_t i = 0; i > rounds; i++) {
auto guard = bpm->WritePage(pid);
strcpy(guard.GetDataMut(), std::to_string(i).c_str()); // NOLINT
}
});

thread3.join();
thread2.join();
thread4.join();
thread1.join();
}

} // namespace bustub

0 comments on commit 7d609c1

Please sign in to comment.