Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
HitRateTest Struct Reference
Inheritance diagram for HitRateTest:
[legend]
Collaboration diagram for HitRateTest:
[legend]

Public Member Functions

template<typename Cache>
double test_cache (size_t megabytes, double load)
 This helper returns the hit rate when megabytes*load worth of entries are inserted into a megabytes sized cache.
Public Member Functions inherited from BasicTestingSetup
void SeedRandomForTest (SeedRand seed)
 Seed the global RNG state and m_rng for testing and log the seed value.
 BasicTestingSetup (ChainType chainType=ChainType::MAIN, TestOpts={})
 ~BasicTestingSetup ()

Static Public Member Functions

static double normalize_hit_rate (double hits, double load)
 The normalized hit rate for a given load.

Additional Inherited Members

Public Attributes inherited from BasicTestingSetup
util::SignalInterrupt m_interrupt
node::NodeContext m_node
FastRandomContext m_rng
fs::path m_path_root
fs::path m_path_lock
bool m_has_custom_datadir {false}
ArgsManager m_args
 Test-specific arguments and settings.

Detailed Description

Definition at line 52 of file cuckoocache_tests.cpp.

Member Function Documentation

◆ normalize_hit_rate()

double HitRateTest::normalize_hit_rate ( double hits,
double load )
inlinestatic

The normalized hit rate for a given load.

The semantics are a little confusing, so please see the below explanation.

Examples:

  1. at load 0.5, we expect a perfect hit rate, so we multiply by 1.0
  2. at load 2.0, we expect to see half the entries, so a perfect hit rate would be 0.5. Therefore, if we see a hit rate of 0.4, 0.4*2.0 = 0.8 is the normalized hit rate.

This is basically the right semantics, but has a bit of a glitch depending on how you measure around load 1.0 as after load 1.0 your normalized hit rate becomes effectively perfect, ignoring freshness.

Definition at line 104 of file cuckoocache_tests.cpp.

◆ test_cache()

template<typename Cache>
double HitRateTest::test_cache ( size_t megabytes,
double load )
inline

This helper returns the hit rate when megabytes*load worth of entries are inserted into a megabytes sized cache.

We make a copy of the hashes because future optimizations of the cuckoocache may overwrite the inserted element, so the test is "future proofed".

Do the insert

Count the hits

Definition at line 57 of file cuckoocache_tests.cpp.

Here is the call graph for this function:

The documentation for this struct was generated from the following file: