Parallelize individual table reads/writes for modest gains.
This commit is contained in:
parent
8f10dff3a0
commit
75144e21ee
1 changed files with 15 additions and 5 deletions
20
src/test.rs
20
src/test.rs
|
@ -34,10 +34,20 @@ async fn test_mysql() -> Result<(), Error> {
|
|||
let pool = TestPool::try_new().await?;
|
||||
crate::load_data(&pool).await?;
|
||||
time_test::time_test!();
|
||||
crate::convert_data(&pool, "employees").await?;
|
||||
crate::convert_data(&pool, "departments").await?;
|
||||
<mysql_async::Pool as Clone>::clone(&pool)
|
||||
.disconnect()
|
||||
.await?;
|
||||
let tables = vec!["employees", "departments"];
|
||||
let mut handles: Vec<tokio::task::JoinHandle<Result<(), crate::Error>>> = vec![];
|
||||
for table in tables {
|
||||
handles.push(tokio::spawn({
|
||||
let pool = pool.clone();
|
||||
let table = table.to_string();
|
||||
async move {
|
||||
crate::convert_data(&pool, &table).await?;
|
||||
Ok(())
|
||||
}
|
||||
}));
|
||||
}
|
||||
for handle in handles {
|
||||
let _ = handle.await?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue