```rust use mobc::Error; use mobc::Pool; use mobcpostgres::tokiopostgres; use mobcpostgres::PostgresConnectionManager; use std::str::FromStr; use std::time::Instant; use tokio::prelude::*; use tokio::sync::mpsc; use tokiopostgres::Config; use tokiopostgres::Error as PostgresError; use tokiopostgres::NoTls;
const MAX: usize = 5000;
async fn simplequery(
pool: Pool
async fn dopostgres(sender: mpsc::Sender<()>) -> Result<(), Error
for _ in 0..MAX {
let pool = pool.clone();
let tx = sender.clone();
tokio::spawn(simple_query(pool, tx).map(|_| ()));
}
Ok(())
}
async fn main() { let mark = Instant::now(); let (tx, mut rx) = mpsc::channel::<()>(MAX);
if let Err(e) = do_postgres(tx).await {
println!("some error {}", e.to_string());
}
let mut num: usize = 0;
while let Some(_) = rx.next().await {
num += 1;
if num == MAX {
break;
}
}
println!("cost {:?}", mark.elapsed());
}
```