Skip to content

Commit dd890fa

Browse files
committedDec 2, 2024
q146: replace lfu with lru
1 parent b2c114b commit dd890fa

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed
 

‎implementations/q146_lru_cache/benches/bench_all_impl.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use q146_lru_cache::impl_v2::LRUCache as LRUCache_v2;
2727
use q146_lru_cache::impl_v3::LRUCache as LRUCache_v3;
2828
use q146_lru_cache::impl_v4::LRUCache as LRUCache_v4;
2929

30-
macro_rules! bench_lfu_cache {
30+
macro_rules! bench_lru_cache {
3131
($bench_name:ident, $cache_type:ty) => {
3232
fn $bench_name(c: &mut Criterion) {
3333
// Define the capacity as a constant or parameter
@@ -55,16 +55,16 @@ macro_rules! bench_lfu_cache {
5555
};
5656
}
5757

58-
bench_lfu_cache!(bench_lfu_cache_v1, LRUCache_v1);
59-
bench_lfu_cache!(bench_lfu_cache_v2, LRUCache_v2);
60-
bench_lfu_cache!(bench_lfu_cache_v3, LRUCache_v3);
61-
bench_lfu_cache!(bench_lfu_cache_v4, LRUCache_v4);
58+
bench_lru_cache!(bench_lru_cache_v1, LRUCache_v1);
59+
bench_lru_cache!(bench_lru_cache_v2, LRUCache_v2);
60+
bench_lru_cache!(bench_lru_cache_v3, LRUCache_v3);
61+
bench_lru_cache!(bench_lru_cache_v4, LRUCache_v4);
6262

6363
criterion_group!(
6464
benches,
65-
bench_lfu_cache_v1,
66-
bench_lfu_cache_v2,
67-
bench_lfu_cache_v3,
68-
bench_lfu_cache_v4,
65+
bench_lru_cache_v1,
66+
bench_lru_cache_v2,
67+
bench_lru_cache_v3,
68+
bench_lru_cache_v4,
6969
);
7070
criterion_main!(benches);

‎implementations/q146_lru_cache/tests/proptest.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn operation_sequence_strategy() -> impl Strategy<Value = Vec<CacheOperation>> {
2828
prop::collection::vec(cache_operation_strategy(), 1..=200)
2929
}
3030

31-
fn test_lfu_cache_with_operations(capacity: i32, operations: Vec<CacheOperation>) {
31+
fn test_lru_cache_with_operations(capacity: i32, operations: Vec<CacheOperation>) {
3232
use q146_lru_cache::impl_v1::LRUCache as LRUCache_v1;
3333
use q146_lru_cache::impl_v2::LRUCache as LRUCache_v2;
3434
use q146_lru_cache::impl_v3::LRUCache as LRUCache_v3;
@@ -63,9 +63,9 @@ fn test_lfu_cache_with_operations(capacity: i32, operations: Vec<CacheOperation>
6363
}
6464

6565
#[test]
66-
fn test_lfu_cache_implementations() {
66+
fn test_lru_cache_implementations() {
6767
let config = ProptestConfig::with_cases(10); // Number of test cases to generate
6868
proptest!(config, |(capacity in 1..=3_000i32, operations in operation_sequence_strategy())| {
69-
test_lfu_cache_with_operations(capacity, operations);
69+
test_lru_cache_with_operations(capacity, operations);
7070
});
7171
}

0 commit comments

Comments
 (0)