1212 Sieve ,
1313 TinyLFU ,
1414 TwoQ ,
15- create_cache ,
1615)
1716from tests .utils import get_reference_data
1817
1918
2019@pytest .mark .parametrize ("eviction_algo" , [
2120 FIFO ,
2221 ARC ,
23- # Clock,
24- # LRU,
25- # S3FIFO,
26- # Sieve,
27- # TinyLFU,
28- # TwoQ,
22+ Clock ,
23+ LRU ,
24+ S3FIFO ,
25+ Sieve ,
26+ TinyLFU ,
27+ TwoQ ,
2928])
3029@pytest .mark .parametrize ("cache_size_ratio" , [0.01 ])
3130def test_eviction_algo (eviction_algo , cache_size_ratio , mock_reader ):
@@ -35,7 +34,7 @@ def test_eviction_algo(eviction_algo, cache_size_ratio, mock_reader):
3534 cache = eviction_algo (cache_size = int (mock_reader .get_wss ()* cache_size_ratio ))
3635 req_count = 0
3736 miss_count = 0
38-
37+
3938 # Limit the number of requests to avoid long test times
4039 # max_requests = 1000
4140 for i , req in enumerate (mock_reader ):
@@ -45,50 +44,18 @@ def test_eviction_algo(eviction_algo, cache_size_ratio, mock_reader):
4544 if not hit :
4645 miss_count += 1
4746 req_count += 1
48-
47+
4948 if req_count == 0 :
5049 pytest .skip ("No requests processed" )
51-
50+
5251 miss_ratio = miss_count / req_count
5352 reference_miss_ratio = get_reference_data (eviction_algo .__name__ , cache_size_ratio )
5453 if reference_miss_ratio is None :
5554 pytest .skip (f"No reference data for { eviction_algo .__name__ } with cache size ratio { cache_size_ratio } " )
5655 assert abs (miss_ratio - reference_miss_ratio ) < 0.01 , f"Miss ratio { miss_ratio } is not close to reference { reference_miss_ratio } "
57-
56+
5857 except Exception as e :
5958 print (f"Error in test_eviction_algo: { e } " )
6059 raise
6160 finally :
6261 pass
63-
64-
65- # @pytest.mark.parametrize("eviction_algo", [
66- # "FIFO",
67- # "ARC",
68- # "Clock",
69- # "LRU",
70- # "S3FIFO",
71- # "Sieve",
72- # "TinyLFU",
73- # "TwoQ",
74- # ])
75- # @pytest.mark.parametrize("cache_size_ratio", [0.01, 0.1])
76- # def test_eviction_algo_generic(eviction_algo, cache_size_ratio, mock_reader):
77- # cache = create_cache(eviction_algo=eviction_algo,
78- # cache_size=int(mock_reader.get_wss()*cache_size_ratio),
79- # eviction_params="",
80- # consider_obj_metadata=False)
81- # req_count = 0
82- # miss_count = 0
83- # for req in mock_reader:
84- # hit = cache.get(req)
85- # if not hit:
86- # miss_count += 1
87- # req_count += 1
88-
89- # miss_ratio = miss_count / req_count
90- # print("Check eviction algo: ", eviction_algo, "with cache size ratio: ", cache_size_ratio)
91- # reference_miss_ratio = get_reference_data(eviction_algo, cache_size_ratio)
92- # if reference_miss_ratio is None:
93- # pytest.skip(f"No reference data for {eviction_algo} with cache size ratio {cache_size_ratio}")
94- # assert abs(miss_ratio - reference_miss_ratio) < 0.01, f"Miss ratio {miss_ratio} is not close to reference {reference_miss_ratio}"
0 commit comments