@@ -95,115 +95,33 @@ Y_UNIT_TEST_SUITE(TClockProCache) {
9595 }
9696
9797 Y_UNIT_TEST (Touch) {
98- TClockProCache<TPage, TPageTraits> cache (100 );
98+ TClockProCache<TPage, TPageTraits> cache (10 );
99+
100+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " " );
99101
100102 TPage page1{1 , 2 };
101103 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{});
102- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
103- << " SmallQueue: {1 0f 2b}" << Endl
104- << " MainQueue: " << Endl
105- << " GhostQueue: " ));
104+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Cold>Test>{1 C 0r 2b}" );
106105
107106 TPage page2{2 , 3 };
108107 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
109- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
110- << " SmallQueue: {1 0f 2b}, {2 0f 3b}" << Endl
111- << " MainQueue: " << Endl
112- << " GhostQueue: " ));
113-
108+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Test>{1 C 0r 2b}, Cold>{2 C 0r 3b}" );
109+
114110 TPage page3{3 , 4 };
115111 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
116- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
117- << " SmallQueue: {1 0f 2b}, {2 0f 3b}, {3 0f 4b}" << Endl
118- << " MainQueue: " << Endl
119- << " GhostQueue: " ));
112+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Test>{1 C 0r 2b}, Cold>{2 C 0r 3b}, {3 C 0r 4b}" );
120113
121114 TPage page4{4 , 1 };
122115 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page4), TVector<ui32>{});
123- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
124- << " SmallQueue: {1 0f 2b}, {2 0f 3b}, {3 0f 4b}, {4 0f 1b}" << Endl
125- << " MainQueue: " << Endl
126- << " GhostQueue: " ));
116+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Test>{1 C 0r 2b}, Cold>{2 C 0r 3b}, {3 C 0r 4b}, {4 C 0r 1b}" );
127117
128118 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{});
129- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{});
130- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
131119 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
132- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
133- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
134- << " SmallQueue: {1 2f 2b}, {2 1f 3b}, {3 2f 4b}, {4 0f 1b}" << Endl
135- << " MainQueue: " << Endl
136- << " GhostQueue: " ));
137-
138- TPage page5{5 , 8 };
139- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page5), TVector<ui32>{2 });
140- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
141- << " SmallQueue: {4 0f 1b}, {5 0f 8b}" << Endl
142- << " MainQueue: {1 2f 2b}, {3 2f 4b}" << Endl
143- << " GhostQueue: {2 3b}" ));
144-
145- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
146- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
147- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
148- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
149- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
150- << " SmallQueue: {4 0f 1b}, {5 0f 8b}" << Endl
151- << " MainQueue: {1 2f 2b}, {3 3f 4b}" << Endl
152- << " GhostQueue: {2 3b}" ));
153-
154- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
155- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
156- << " SmallQueue: {4 0f 1b}, {5 0f 8b}" << Endl
157- << " MainQueue: {1 2f 2b}, {3 3f 4b}, {2 0f 3b}" << Endl
158- << " GhostQueue: " ));
159- }
120+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Test>{1 C 1r 2b}, Cold>{2 C 0r 3b}, {3 C 1r 4b}, {4 C 0r 1b}" );
160121
161- Y_UNIT_TEST (Touch_MainQueue) {
162- TClockProCache<TPage, TPageTraits> cache (100 );
163-
164- TPage page1{1 , 20 };
165- TPage page2{2 , 30 };
166- TPage page3{3 , 40 };
167- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{1 });
168- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{2 });
169- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{3 });
170- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
171- << " SmallQueue: " << Endl
172- << " MainQueue: " << Endl
173- << " GhostQueue: {1 20b}, {2 30b}, {3 40b}" ));
174-
175- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
176- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{});
177- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
178- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
179- << " SmallQueue: " << Endl
180- << " MainQueue: {2 0f 30b}, {1 0f 20b}, {3 0f 40b}" << Endl
181- << " GhostQueue: " ));
182-
183- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page1), TVector<ui32>{});
184- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
185- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page2), TVector<ui32>{});
186- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
187- << " SmallQueue: " << Endl
188- << " MainQueue: {2 2f 30b}, {1 1f 20b}, {3 0f 40b}" << Endl
189- << " GhostQueue: " ));
190-
191- TPage page4{4 , 20 };
192- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page4), TVector<ui32>{4 });
193- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
194- << " SmallQueue: " << Endl
195- << " MainQueue: {2 2f 30b}, {1 1f 20b}, {3 0f 40b}" << Endl
196- << " GhostQueue: {4 20b}" ));
197-
198- UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page4), TVector<ui32>{3 });
199- // MainQueue: {2 2f 30b}, {1 1f 20b}, {3 0f 40b}, {4 0f 20b}
200- // MainQueue: {1 1f 20b}, {3 0f 40b}, {4 0f 20b}, {2 1f 30b}
201- // MainQueue: {3 0f 40b}, {4 0f 20b}, {2 1f 30b}, {1 0f 20b}
202- // MainQueue: {4 0f 20b}, {2 1f 30b}, {1 0f 20b}
203- UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
204- << " SmallQueue: " << Endl
205- << " MainQueue: {4 0f 20b}, {2 1f 30b}, {1 0f 20b}" << Endl
206- << " GhostQueue: " ));
122+ TPage page5{5 , 1 };
123+ UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page5), TVector<ui32>{});
124+ UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), " Hot>Test>{1 C 1r 2b}, Cold>{2 C 0r 3b}, {3 C 1r 4b}, {4 C 0r 1b}, {5 C 0r 1b}" );
207125 }
208126
209127 Y_UNIT_TEST (EvictNext) {
@@ -227,31 +145,31 @@ Y_UNIT_TEST_SUITE(TClockProCache) {
227145 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
228146 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
229147 << " SmallQueue: " << Endl
230- << " MainQueue: {2 0f 30b}, {1 1f 20b}, {3 0f 40b}" << Endl
148+ << " MainQueue: {2 0r 30b}, {1 1r 20b}, {3 0r 40b}" << Endl
231149 << " GhostQueue: " ));
232150
233151 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page4), TVector<ui32>{});
234152 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
235- << " SmallQueue: {4 0f 10b}" << Endl
236- << " MainQueue: {2 0f 30b}, {1 1f 20b}, {3 0f 40b}" << Endl
153+ << " SmallQueue: {4 0r 10b}" << Endl
154+ << " MainQueue: {2 0r 30b}, {1 1r 20b}, {3 0r 40b}" << Endl
237155 << " GhostQueue: " ));
238156
239157 UNIT_ASSERT_VALUES_EQUAL (EvictNext (cache), 4 );
240158 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
241159 << " SmallQueue: " << Endl
242- << " MainQueue: {2 0f 30b}, {1 1f 20b}, {3 0f 40b}" << Endl
160+ << " MainQueue: {2 0r 30b}, {1 1r 20b}, {3 0r 40b}" << Endl
243161 << " GhostQueue: {4 10b}" ));
244162
245163 UNIT_ASSERT_VALUES_EQUAL (EvictNext (cache), 2 );
246164 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
247165 << " SmallQueue: " << Endl
248- << " MainQueue: {1 1f 20b}, {3 0f 40b}" << Endl
166+ << " MainQueue: {1 1r 20b}, {3 0r 40b}" << Endl
249167 << " GhostQueue: {4 10b}" ));
250168
251169 UNIT_ASSERT_VALUES_EQUAL (EvictNext (cache), 3 );
252170 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
253171 << " SmallQueue: " << Endl
254- << " MainQueue: {1 0f 20b}" << Endl
172+ << " MainQueue: {1 0r 20b}" << Endl
255173 << " GhostQueue: {4 10b}" ));
256174
257175 UNIT_ASSERT_VALUES_EQUAL (EvictNext (cache), 1 );
@@ -287,21 +205,21 @@ Y_UNIT_TEST_SUITE(TClockProCache) {
287205 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page3), TVector<ui32>{});
288206 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
289207 << " SmallQueue: " << Endl
290- << " MainQueue: {2 0f 30b}, {1 0f 20b}, {3 0f 40b}" << Endl
208+ << " MainQueue: {2 0r 30b}, {1 0r 20b}, {3 0r 40b}" << Endl
291209 << " GhostQueue: " ));
292210
293211 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page4), TVector<ui32>{});
294212 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
295- << " SmallQueue: {4 0f 10b}" << Endl
296- << " MainQueue: {2 0f 30b}, {1 0f 20b}, {3 0f 40b}" << Endl
213+ << " SmallQueue: {4 0r 10b}" << Endl
214+ << " MainQueue: {2 0r 30b}, {1 0r 20b}, {3 0r 40b}" << Endl
297215 << " GhostQueue: " ));
298216
299217 cache.UpdateLimit (45 );
300218 TPage page5{5 , 1 };
301219 UNIT_ASSERT_VALUES_EQUAL (Touch (cache, page5), (TVector<ui32>{4 , 2 , 1 }));
302220 UNIT_ASSERT_VALUES_EQUAL (cache.Dump (), (TString)(TStringBuilder ()
303- << " SmallQueue: {5 0f 1b}" << Endl
304- << " MainQueue: {3 0f 40b}" << Endl
221+ << " SmallQueue: {5 0r 1b}" << Endl
222+ << " MainQueue: {3 0r 40b}" << Endl
305223 << " GhostQueue: {4 10b}" ));
306224
307225 cache.UpdateLimit (0 );
0 commit comments