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?;
|
let pool = TestPool::try_new().await?;
|
||||||
crate::load_data(&pool).await?;
|
crate::load_data(&pool).await?;
|
||||||
time_test::time_test!();
|
time_test::time_test!();
|
||||||
crate::convert_data(&pool, "employees").await?;
|
let tables = vec!["employees", "departments"];
|
||||||
crate::convert_data(&pool, "departments").await?;
|
let mut handles: Vec<tokio::task::JoinHandle<Result<(), crate::Error>>> = vec![];
|
||||||
<mysql_async::Pool as Clone>::clone(&pool)
|
for table in tables {
|
||||||
.disconnect()
|
handles.push(tokio::spawn({
|
||||||
.await?;
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue