Helper function to get cache constructor by algorithm name
| 40 | |
| 41 | // Helper function to get cache constructor by algorithm name |
| 42 | cache_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 |
| 58 | Napi::Value runSimulation(const Napi::CallbackInfo& info) { |
no test coverage detected