Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

chore(export-benchmark): write runs to a per-process temp dir, drop narrating comment

Vagarth3bc89760340e
diff --git a/apps/desktop-gpui/Cargo.lock b/apps/desktop-gpui/Cargo.lock
index 4d2ac0436..8a41257d6 100644
--- a/apps/desktop-gpui/Cargo.lock
+++ b/apps/desktop-gpui/Cargo.lock
@@ -1584,6 +1584,7 @@ dependencies = [
"sha2",
"smallvec",
"tauri-winres",
+ "tempfile",
"tiny-skia",
"tokio",
"tracing",
diff --git a/apps/desktop-gpui/Cargo.toml b/apps/desktop-gpui/Cargo.toml
index c803d72db..f3a193603 100644
--- a/apps/desktop-gpui/Cargo.toml
+++ b/apps/desktop-gpui/Cargo.toml
@@ -170,6 +170,7 @@ tauri-winres = "0.3.5"
# runtime would deadlock the moment the test thread blocks on a frame. Kept in
# dev-dependencies so the shipped binary's tokio features are unchanged.
tokio = { version = "1", features = ["rt-multi-thread", "time", "test-util"] }
+tempfile = "3"
[target.'cfg(unix)'.dependencies]
libc = "0.2"
diff --git a/apps/desktop-gpui/examples/export-benchmark.rs b/apps/desktop-gpui/examples/export-benchmark.rs
index 4c10debc3..58b842ff2 100644
--- a/apps/desktop-gpui/examples/export-benchmark.rs
+++ b/apps/desktop-gpui/examples/export-benchmark.rs
@@ -1,7 +1,3 @@
-//! Exports a project to MP4 the way the GPUI export page does (`run_export` in
-//! `src/editor_export.rs`) and reports wall time, frames per second and process
-//! CPU time.
-//!
//! Run: cargo run --release --example export-benchmark -- <project.cap> [WIDTH] [HEIGHT] [FPS] [RUNS]
use std::{
@@ -54,11 +50,9 @@ fn cpu_secs() -> f64 {
}
async fn run(project_path: PathBuf, size: XY<u32>, fps: u32, runs: u32) -> anyhow::Result<()> {
- let output_dir = std::env::temp_dir().join("cap-export-benchmark");
- std::fs::create_dir_all(&output_dir)?;
+ let output_dir = tempfile::tempdir()?;
for run in 0..runs {
- let output_path = output_dir.join(format!("run-{run}.mp4"));
- let _ = std::fs::remove_file(&output_path);
+ let output_path = output_dir.path().join(format!("run-{run}.mp4"));
let cancel = Arc::new(AtomicBool::new(false));
let started = Instant::now();
let cpu_started = cpu_secs();