Added basic mutation buffer insert/lookup test.

This commit is contained in:
Steve Atherton 2020-02-24 00:31:09 -08:00
parent 1e45bb2be3
commit 72a549df14
1 changed files with 30 additions and 0 deletions

View File

@ -3284,6 +3284,7 @@ private:
}
};
public:
struct MutationBuffer {
MutationBuffer() {
// Create range representing the entire keyspace. This reduces edge cases to applying mutations
@ -3382,6 +3383,7 @@ private:
};
private:
/* Mutation Buffer Overview
*
* This structure's organization is meant to put pending updates for the btree in an order
@ -6265,6 +6267,34 @@ struct SimpleCounter {
std::string toString() { return format("%" PRId64 "/%.2f/%.2f", x, rate() / 1e6, avgRate() / 1e6); }
};
TEST_CASE("!/redwood/performance/mutationBuffer") {
// This test uses pregenerated short random keys
int count = 10e6;
printf("Generating %d strings...\n", count);
Arena arena;
std::vector<KeyRef> strings;
while(strings.size() < count) {
strings.push_back(randomString(arena, 5));
}
printf("Inserting and then finding each string...\n", count);
double start = timer();
VersionedBTree::MutationBuffer m;
for(int i = 0; i < count; ++i) {
KeyRef key = strings[i];
auto a = m.insert(key);
auto b = m.lower_bound(key);
ASSERT(a == b);
m.erase(a, b);
}
double elapsed = timer() - start;
printf("count=%d elapsed=%f\n", count, elapsed);
return Void();
}
TEST_CASE("!/redwood/correctness/btree") {
state std::string pagerFile = "unittest_pageFile.redwood";
IPager2 *pager;