fn benchmark_cache_get_mt()

in chunk_cache_bench/benches/cache_bench.rs [41:69]


fn benchmark_cache_get_mt<T: ChunkCacheExt + 'static>(c: &mut Criterion) {
    let cache_root = TempDir::new(format!("benchmark_cache_get_mt_{}", T::name()).as_str()).unwrap();
    let cache = T::_initialize(cache_root.path().to_path_buf(), CAPACITY).unwrap();

    let mut it: RandomEntryIterator<StdRng> = RandomEntryIterator::from_seed(SEED).with_range_len(RANGE_LEN);

    for _ in 0..NUM_PUTS {
        let (key, range, offsets, data) = it.next().unwrap();
        cache.put(&key, &range, &offsets, &data).unwrap();
    }

    let rt = tokio::runtime::Runtime::new().unwrap();

    c.bench_with_input(BenchmarkId::new("cache_get_mt", T::name()), &0, |b, _| {
        b.to_async(&rt).iter(|| async {
            let mut handles = JoinSet::new();
            for _ in 0..NUM_CONCURRENT_TASKS {
                let c = cache.clone();
                handles.spawn(async move {
                    let mut rng = thread_rng();
                    let key = random_key(&mut rng);
                    let range = random_range(&mut rng);
                    c.get(&key, &range).unwrap()
                });
            }
            handles.join_all().await;
        });
    });
}