Changeset View
Changeset View
Standalone View
Standalone View
src/test/cuckoocache_tests.cpp
Show First 20 Lines • Show All 378 Lines • ▼ Show 20 Lines | for (uint32_t i = 0; i < total; ++i) { | ||||
} | } | ||||
// We use last_few.size() rather than WINDOW_SIZE for the correct | // We use last_few.size() rather than WINDOW_SIZE for the correct | ||||
// behavior on the first WINDOW_SIZE iterations where the deque is not | // behavior on the first WINDOW_SIZE iterations where the deque is not | ||||
// full yet. | // full yet. | ||||
double hit = double(count) / (last_few.size() * POP_AMOUNT); | double hit = double(count) / (last_few.size() * POP_AMOUNT); | ||||
// Loose Check that hit rate is above min_hit_rate | // Loose Check that hit rate is above min_hit_rate | ||||
BOOST_CHECK(hit > min_hit_rate); | BOOST_CHECK(hit > min_hit_rate); | ||||
// Tighter check, count number of times we are less than tight_hit_rate | // Tighter check, count number of times we are less than tight_hit_rate | ||||
// (and implicityly, greater than min_hit_rate) | // (and implicitly, greater than min_hit_rate) | ||||
out_of_tight_tolerance += hit < tight_hit_rate; | out_of_tight_tolerance += hit < tight_hit_rate; | ||||
} | } | ||||
// Check that being out of tolerance happens less than | // Check that being out of tolerance happens less than | ||||
// max_rate_less_than_tight_hit_rate of the time | // max_rate_less_than_tight_hit_rate of the time | ||||
BOOST_CHECK(double(out_of_tight_tolerance) / double(total) < | BOOST_CHECK(double(out_of_tight_tolerance) / double(total) < | ||||
max_rate_less_than_tight_hit_rate); | max_rate_less_than_tight_hit_rate); | ||||
} | } | ||||
BOOST_AUTO_TEST_CASE(cuckoocache_generations) { | BOOST_AUTO_TEST_CASE(cuckoocache_generations) { | ||||
test_cache_generations<CuckooCache::cache<uint256, SignatureCacheHasher>>(); | test_cache_generations<CuckooCache::cache<uint256, SignatureCacheHasher>>(); | ||||
} | } | ||||
BOOST_AUTO_TEST_SUITE_END(); | BOOST_AUTO_TEST_SUITE_END(); |