async-std
async-std copied to clipboard
couldn't find bench macro in async_std
It seems I cannot have async_std::bench
attribute even when I activate attributes
feature
Anyone knows how to avoid using block_on
in rust bench:
b.iter(|| // how to execute async function here using async_std)
seems like block_on
is a little bit heavy and I would like to avoid using block_on
in bench iter
@GopherJ you can use https://docs.rs/futures/0.3.4/futures/executor/index.html and task::spawn https://docs.rs/async-std/1.5.0/async_std/task/index.html#spawning-a-task
@humb1t I think it's not a good idea to create an async runtime in bench iterator, because in that case the creating time will be counted in.
you can create ThreadPool
before b.iter()
and use one runtime for entire benchmark like you do to preconfigure another environment entities.
@humb1t could you give an example? because for me I don't think it'll work because I still cannot use async code in b.iter
It seems I cannot have
async_std::bench
attribute even when I activateattributes
feature
See also https://github.com/async-rs/async-attributes/issues/9 and https://github.com/async-rs/async-std/issues/70#issuecomment-528042987
@GopherJ sorry - didn't check notifications for a while.
https://github.com/hyperledger/iroha/blob/iroha2-dev/iroha_client/benches/torii.rs this is our current benches, but we block inside iter.
@humb1t hi no pb. I think block_on
inside iter will give incorrect figures. especially for [email protected]
and tokio