mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-23 08:28:21 +00:00
One more
This commit is contained in:
@@ -309,6 +309,9 @@ DataBucketsRepository::DataBuckets DataBucket::GetData(const DataBucketKey &k_,
|
|||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if we can cache its assumed we didn't load this into the cache so we should not return a miss
|
||||||
|
return DataBucketsRepository::NewEntity(); // Not found in cache
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fetch the value from the database
|
// Fetch the value from the database
|
||||||
|
|||||||
@@ -195,6 +195,25 @@ void RunBenchmarkCycle(uint64_t target_rows)
|
|||||||
std::cout << "✅ Completed " << Strings::Commify(OPERATIONS_PER_TEST) << " cached reads in "
|
std::cout << "✅ Completed " << Strings::Commify(OPERATIONS_PER_TEST) << " cached reads in "
|
||||||
<< read_cached_time.count() << " seconds. (DataBucket::GetData)\n";
|
<< read_cached_time.count() << " seconds. (DataBucket::GetData)\n";
|
||||||
|
|
||||||
|
// 🔍 **Measure Client-Scoped Cache Miss Performance (Skips DB via CanCache)**
|
||||||
|
auto read_client_cache_miss_start = std::chrono::high_resolution_clock::now();
|
||||||
|
for (size_t i = 0; i < OPERATIONS_PER_TEST; ++i) {
|
||||||
|
// generate key that doesn't exist
|
||||||
|
std::string key = "nonexistent_key_" + std::to_string(i);
|
||||||
|
|
||||||
|
DataBucketKey k{
|
||||||
|
.key = key,
|
||||||
|
.character_id = 999999999, // use scoped value
|
||||||
|
};
|
||||||
|
|
||||||
|
DataBucket::GetData(k);
|
||||||
|
}
|
||||||
|
auto read_client_cache_miss_end = std::chrono::high_resolution_clock::now();
|
||||||
|
std::chrono::duration<double> read_client_cache_miss_time = read_client_cache_miss_end - read_client_cache_miss_start;
|
||||||
|
std::cout << "✅ Completed " << Strings::Commify(OPERATIONS_PER_TEST)
|
||||||
|
<< " scoped cache-miss reads (no DB) in "
|
||||||
|
<< read_client_cache_miss_time.count() << " seconds. (Client Scoped, Cache Miss, No DB)\n";
|
||||||
|
|
||||||
// 🔍 **Measure Non-Cached Read Performance (Direct Query)**
|
// 🔍 **Measure Non-Cached Read Performance (Direct Query)**
|
||||||
auto read_uncached_start = std::chrono::high_resolution_clock::now();
|
auto read_uncached_start = std::chrono::high_resolution_clock::now();
|
||||||
for (size_t i = 0; i < OPERATIONS_PER_TEST; ++i) {
|
for (size_t i = 0; i < OPERATIONS_PER_TEST; ++i) {
|
||||||
@@ -262,16 +281,24 @@ void ZoneCLI::BenchmarkDatabuckets(int argc, char **argv, argh::parser &cmd, std
|
|||||||
LogSys.SetDatabase(&database)->LoadLogDatabaseSettings();
|
LogSys.SetDatabase(&database)->LoadLogDatabaseSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
auto start_time = std::chrono::high_resolution_clock::now();
|
LogSys.log_settings[Logs::MySQLQuery].log_to_console = 1;
|
||||||
|
|
||||||
std::vector<uint64_t> benchmark_sizes = {10000, 100000, 1000000};
|
// 🔍 **Measure Client-Scoped Cache Miss Performance (Skips DB via CanCache)**
|
||||||
|
auto read_client_cache_miss_start = std::chrono::high_resolution_clock::now();
|
||||||
|
for (size_t i = 0; i < 5000; ++i) {
|
||||||
|
// generate key that doesn't exist
|
||||||
|
std::string key = "nonexistent_key_" + std::to_string(i);
|
||||||
|
|
||||||
for (auto size: benchmark_sizes) {
|
DataBucketKey k{
|
||||||
RunBenchmarkCycle(size);
|
.key = key,
|
||||||
|
.character_id = 999999999, // use scoped value
|
||||||
|
};
|
||||||
|
|
||||||
|
DataBucket::GetData(k);
|
||||||
}
|
}
|
||||||
|
auto read_client_cache_miss_end = std::chrono::high_resolution_clock::now();
|
||||||
// 🚀 **Total Benchmark Time**
|
std::chrono::duration<double> read_client_cache_miss_time = read_client_cache_miss_end - read_client_cache_miss_start;
|
||||||
auto end_time = std::chrono::high_resolution_clock::now();
|
std::cout << "✅ Completed " << Strings::Commify(5000)
|
||||||
std::chrono::duration<double> total_elapsed = end_time - start_time;
|
<< " scoped cache-miss reads (no DB) in "
|
||||||
std::cout << "\n🚀 Total Benchmark Time: " << total_elapsed.count() << " seconds\n";
|
<< read_client_cache_miss_time.count() << " seconds. (Client Scoped, Cache Miss, No DB)\n";
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user