diff --git a/.changes/async.md b/.changes/async.md new file mode 100644 index 0000000..8364709 --- /dev/null +++ b/.changes/async.md @@ -0,0 +1,5 @@ +--- +"eval-stack": patch:perf +--- + +Improve the performance of the async I/O operations. diff --git a/src/case.rs b/src/case.rs index 77a9c8b..c60931b 100644 --- a/src/case.rs +++ b/src/case.rs @@ -1,6 +1,7 @@ -use std::{fs::create_dir_all, path::PathBuf, time::Duration}; +use std::{path::PathBuf, time::Duration}; use anyhow::Result; +use tokio::fs::{create_dir_all, remove_dir_all}; use which::which; use crate::{ @@ -25,7 +26,7 @@ where let workspace: PathBuf = workspace.into(); if !workspace.exists() { - create_dir_all(&workspace)?; + create_dir_all(&workspace).await?; } let source_file_path = Into::::into(source_file_path) @@ -97,7 +98,7 @@ where } if clean { - if let Err(e) = std::fs::remove_dir_all(workspace) { + if let Err(e) = remove_dir_all(workspace).await { anyhow::bail!("Failed to remove workspace: {}", e); } } diff --git a/src/engine/runtime.rs b/src/engine/runtime.rs index 6d9768c..c8fb814 100644 --- a/src/engine/runtime.rs +++ b/src/engine/runtime.rs @@ -98,7 +98,7 @@ pub async fn handle_submission( submission .test_cases .into_iter() - .map(|_tc| ("tests/1.in", "tests/1.out")) + .map(|tc| (tc.input, tc.output)) .collect(), true, )