MCPcopy Create free account
hub / github.com/1a1a11a/libCacheSim / createCache

Function createCache

libCacheSim-node/binding.cc:42–55  ·  view source on GitHub ↗

Helper function to get cache constructor by algorithm name

Source from the content-addressed store, hash-verified

40
41// Helper function to get cache constructor by algorithm name
42cache_t* createCache(const std::string& algo, const common_cache_params_t& params) {
43 std::string lowerAlgo = algo;
44 std::transform(lowerAlgo.begin(), lowerAlgo.end(), lowerAlgo.begin(), ::tolower);
45
46 if (lowerAlgo == "lru") return LRU_init(params, nullptr);
47 else if (lowerAlgo == "fifo") return FIFO_init(params, nullptr);
48 else if (lowerAlgo == "lfu") return LFU_init(params, nullptr);
49 else if (lowerAlgo == "arc") return ARC_init(params, nullptr);
50 else if (lowerAlgo == "clock") return Clock_init(params, nullptr);
51 else if (lowerAlgo == "s3fifo") return S3FIFO_init(params, nullptr);
52 else if (lowerAlgo == "sieve") return Sieve_init(params, nullptr);
53
54 return nullptr; // Unknown algorithm
55}
56
57// Main simulation function
58Napi::Value runSimulation(const Napi::CallbackInfo& info) {

Callers 1

runSimulationFunction · 0.85

Calls 9

LRU_initFunction · 0.85
FIFO_initFunction · 0.85
LFU_initFunction · 0.85
ARC_initFunction · 0.85
Clock_initFunction · 0.85
S3FIFO_initFunction · 0.85
Sieve_initFunction · 0.85
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected