Skip to content

Commit

Permalink
perf(async): improve async io (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
fu050409 authored Dec 4, 2024
1 parent c499b94 commit 0bf9b63
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changes/async.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"eval-stack": patch:perf
---

Improve the performance of the async I/O operations.
7 changes: 4 additions & 3 deletions src/case.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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::<PathBuf>::into(source_file_path)
Expand Down Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/engine/runtime.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down

0 comments on commit 0bf9b63

Please sign in to comment.