async fn do_something<M: AsyncMap<Key = String, Value = String> + 'static>(
    size: usize,
    keys: Arc<Vec<Vec<(String, String)>>>,
    factory: fn() -> M,
) {
    let map: M = factory();

    let mut handles = Vec::new();

    for thread in 0..size {
        let map = map.clone();
        let keys = keys.clone();

        handles.push(tokio::task::spawn(async move {
            for step in 0..1000 {
                let step_pair: &(String, String) = &(keys[(step / 100) % 10][(step + thread) % 10]);

                let future = map.get(
                    &step_pair.0,
                    Box::new(move |key: &String| format!("Valu: {}", key))
                        as Box<dyn AsyncFactory<String, String>>,
                );

                let value = future.await;

                assert_eq!(*step_pair.1, value);
            }
        }));
    }

    for handle in handles {
        if let Err(_) = handle.await {
            todo!()
        }
    }
}
// Here we have an async function to benchmark
Here we have an async function to benchmark
Here we have an async function to benchmark
async fn do_something<M: AsyncMap<Key = String, Value = String> + 'static>(
    size: usize,
    keys: Arc<Vec<Vec<(String, String)>>>,
    factory: fn() -> M,
) {
    let map: M = factory();
    let mut handles = Vec::new();
    for thread in 0..size {
        let map = map.clone();
        let keys = keys.clone();
        handles.push(tokio::task::spawn(async move {
            for step in 0..1000 {
                let step_pair: &(String, String) = &(keys[(step / 100) % 10][(step + thread) % 10]);
                let future = map.get(
                    &step_pair.0,
                    Box::new(move |key: &String| format!("Valu: {}", key))
                        as Box<dyn AsyncFactory<String, String>>,
                );
                let value = future.await;
                assert_eq!(*step_pair.1, value);
            }
        }));
    }
    for handle in handles {
        if let Err(_) = handle.await {
            todo!()
        }
    }
}
async fn do_something < M : AsyncMap < Key = String , Value = String > + ' static > ( size : usize , keys : Arc < Vec < Vec < ( String , String ) > > > , factory : fn ( ) -> M , ) { let map : M = factory ( ) ; let mut handles = Vec :: new ( ) ; for thread in 0 .. size { let map = map . clone ( ) ; let keys = keys . clone ( ) ; handles . push ( tokio :: task :: spawn ( async move { for step in 0 .. 1000 { let step_pair : & ( String , String ) = & ( keys [ ( step / 100 ) % 10 ] [ ( step + thread ) % 10 ] ) ; let future = map . get ( & step_pair . 0 , Box :: new ( move | key : & String | format ! ( " " key ) ) as Box < dyn AsyncFactory < String , String > > , ) ; let value = future . await ; assert_eq ! ( step_pair 1 value ) ; } } ) ) ; } for handle in handles { if let Err ( _ ) = handle . await { todo ! ( ) } } }
Here we have an async function to benchmark
Here we have an async function to benchmark
size
usize
keys
Arc<Vec<Vec<(String, String)>>>
factory
fn() -> M
size
usize
keys
Arc<Vec<Vec<(String, String)>>>
factory
fn() -> M