Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

clippy

Richie McIlroy75d578ecd23f
diff --git a/crates/recording/examples/camera-benchmark.rs b/crates/recording/examples/camera-benchmark.rs
index 05f00ff41..5ad07ad52 100644
--- a/crates/recording/examples/camera-benchmark.rs
+++ b/crates/recording/examples/camera-benchmark.rs
@@ -127,10 +127,7 @@ async fn run_camera_encoding_benchmark(
let width = first_frame.inner.width();
let height = first_frame.inner.height();
- println!(
- "\nCamera frame format: {:?} {}x{}",
- input_format, width, height
- );
+ println!("\nCamera frame format: {input_format:?} {width}x{height}");
let output_format = Pixel::NV12;
let needs_conversion = input_format != output_format;
@@ -295,13 +292,12 @@ async fn run_camera_encoding_benchmark(
let encode_start = Instant::now();
let timestamp = Duration::from_micros(converted.frame.pts().unwrap_or(0) as u64);
- match encoder.queue_preconverted_frame(converted.frame, timestamp, &mut output) {
- Ok(()) => {
- let encode_duration = encode_start.elapsed();
- let pipeline_latency = converted.submit_time.elapsed();
- metrics.record_frame_encoded(encode_duration, pipeline_latency);
- }
- Err(_) => {}
+ if let Ok(()) =
+ encoder.queue_preconverted_frame(converted.frame, timestamp, &mut output)
+ {
+ let encode_duration = encode_start.elapsed();
+ let pipeline_latency = converted.submit_time.elapsed();
+ metrics.record_frame_encoded(encode_duration, pipeline_latency);
}
} else {
break;
@@ -374,8 +370,8 @@ async fn main() {
println!("\n=== Frame Rate Test ===");
let (frames, fps, inter_frame_times) = run_camera_frame_rate_test(&camera.0, 3).await;
- println!("Frames captured: {}", frames);
- println!("Average FPS: {:.1}", fps);
+ println!("Frames captured: {frames}");
+ println!("Average FPS: {fps:.1}");
if !inter_frame_times.is_empty() {
let avg_interval: Duration =
@@ -384,9 +380,9 @@ async fn main() {
let min_interval = inter_frame_times.iter().min().unwrap();
println!("Inter-frame timing:");
- println!(" Average: {:?}", avg_interval);
- println!(" Min: {:?}", min_interval);
- println!(" Max: {:?}", max_interval);
+ println!(" Average: {avg_interval:?}");
+ println!(" Min: {min_interval:?}");
+ println!(" Max: {max_interval:?}");
let mut sorted = inter_frame_times.clone();
sorted.sort();
diff --git a/crates/recording/examples/encoding-benchmark.rs b/crates/recording/examples/encoding-benchmark.rs
index 8169e30ff..d9e62ad59 100644
--- a/crates/recording/examples/encoding-benchmark.rs
+++ b/crates/recording/examples/encoding-benchmark.rs
@@ -192,7 +192,7 @@ fn benchmark_conversion_formats(config: &BenchmarkConfig) {
println!("\n=== Format Conversion Benchmarks ===\n");
for (input, output, name) in formats {
- println!("Testing: {}", name);
+ println!("Testing: {name}");
let mut cfg = config.clone();
cfg.duration_secs = 5;
@@ -406,7 +406,7 @@ fn main() {
"encode" => benchmark_encode_times(&config),
"workers" => benchmark_worker_counts(&config),
"resolutions" => benchmark_resolutions(&config),
- "full" | _ => {
+ _ => {
benchmark_conversion_formats(&config);
benchmark_encode_times(&config);
benchmark_worker_counts(&config);
diff --git a/crates/recording/examples/memory-leak-detector.rs b/crates/recording/examples/memory-leak-detector.rs
index 83d9ba616..0e7776573 100644
--- a/crates/recording/examples/memory-leak-detector.rs
+++ b/crates/recording/examples/memory-leak-detector.rs
@@ -39,7 +39,7 @@ fn get_memory_usage() -> Option<MemoryStats> {
};
let (footprint_mb, dirty_mb) = Command::new("footprint")
- .arg(&pid.to_string())
+ .arg(pid.to_string())
.output()
.ok()
.filter(|o| o.status.success())
@@ -128,7 +128,9 @@ struct MemoryStats {
resident_mb: f64,
virtual_mb: f64,
footprint_mb: Option<f64>,
+ #[allow(dead_code)]
dirty_mb: Option<f64>,
+ #[allow(dead_code)]
compressed_mb: Option<f64>,
}
@@ -203,7 +205,7 @@ impl MemoryTracker {
let current = stats.primary_metric();
let delta = current - prev_memory;
let delta_str = if delta.abs() > 0.5 {
- format!("{:+.1}", delta)
+ format!("{delta:+.1}")
} else {
"~0".to_string()
};
@@ -219,10 +221,10 @@ impl MemoryTracker {
}
println!("\n=== Summary ===");
- println!("Duration: {:.1}s", duration_secs);
+ println!("Duration: {duration_secs:.1}s");
println!("Start RSS: {:.1} MB", first.1.primary_metric());
println!("End RSS: {:.1} MB", last.1.primary_metric());
- println!("Total growth: {:.1} MB", memory_growth);
+ println!("Total growth: {memory_growth:.1} MB");
println!(
"Growth rate: {:.2} MB/s ({:.1} MB/10s)",
growth_rate,
@@ -266,10 +268,10 @@ async fn run_memory_test(
) -> Result<(), Box<dyn std::error::Error>> {
println!("=== Cap Memory Leak Detector ===\n");
println!("Configuration:");
- println!(" Duration: {}s", duration_secs);
- println!(" Camera: {}", include_camera);
- println!(" Microphone: {}", include_mic);
- println!(" Fragmented MP4: {}", fragmented);
+ println!(" Duration: {duration_secs}s");
+ println!(" Camera: {include_camera}");
+ println!(" Microphone: {include_mic}");
+ println!(" Fragmented MP4: {fragmented}");
println!();
let mut memory_tracker = MemoryTracker::new();
@@ -310,7 +312,7 @@ async fn run_memory_test(
if include_mic {
if let Some((mic_name, _, _)) = MicrophoneFeed::default_device() {
- println!("Using microphone: {}", mic_name);
+ println!("Using microphone: {mic_name}");
let error_sender = flume::unbounded().0;
let mic_feed = MicrophoneFeed::spawn(MicrophoneFeed::new(error_sender));
@@ -373,7 +375,7 @@ async fn run_memory_test(
memory_tracker.sample();
- println!("Stop took: {:?}", stop_duration);
+ println!("Stop took: {stop_duration:?}");
println!("Output path: {}", result.project_path.display());
memory_tracker.print_report();
@@ -493,16 +495,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Second: Testing WITH fragmented MP4...\n");
run_memory_test(60, include_camera, include_mic, true).await?;
}
- "help" | _ => {
+ _ => {
println!("Cap Memory Leak Detector");
println!();
println!("Usage: memory-leak-detector [OPTIONS]");
println!();
println!("Options:");
- println!(
- " --duration <secs> Test duration (default: {})",
- DEFAULT_DURATION_SECS
- );
+ println!(" --duration <secs> Test duration (default: {DEFAULT_DURATION_SECS})");
println!(" --mode <mode> Test mode:");
println!(" full Full recording pipeline with fragmented MP4 (default)");
println!(" screen-only Screen recording only (no camera/mic)");
diff --git a/crates/recording/examples/recording-benchmark.rs b/crates/recording/examples/recording-benchmark.rs
index 87adbe7da..13eab946f 100644
--- a/crates/recording/examples/recording-benchmark.rs
+++ b/crates/recording/examples/recording-benchmark.rs
@@ -265,7 +265,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
.unwrap_or(5);
stress_test_recording(cycles, config.duration_secs).await?;
}
- "full" | _ => {
+ _ => {
println!("Mode: Full benchmark suite\n");
println!("--- Screen Recording ---");
diff --git a/crates/rendering/src/cpu_yuv.rs b/crates/rendering/src/cpu_yuv.rs
index 7dbb0a26b..ea929e535 100644
--- a/crates/rendering/src/cpu_yuv.rs
+++ b/crates/rendering/src/cpu_yuv.rs
@@ -990,11 +990,7 @@ mod tests {
let diff = (*s as i32 - *d as i32).abs();
assert!(
diff <= 2,
- "Mismatch at index {}: scalar={}, simd={}, diff={}",
- i,
- s,
- d,
- diff
+ "Mismatch at index {i}: scalar={s}, simd={d}, diff={diff}"
);
}
}
@@ -1064,11 +1060,7 @@ mod tests {
let diff = (*a as i32 - *b as i32).abs();
assert!(
diff <= 2,
- "Mismatch at index {}: expected={}, got={}, diff={}",
- i,
- a,
- b,
- diff
+ "Mismatch at index {i}: expected={a}, got={b}, diff={diff}"
);
}
}
@@ -1119,11 +1111,7 @@ mod tests {
let diff = (*s as i32 - *d as i32).abs();
assert!(
diff <= 2,
- "YUV420P mismatch at index {}: scalar={}, simd={}, diff={}",
- i,
- s,
- d,
- diff
+ "YUV420P mismatch at index {i}: scalar={s}, simd={d}, diff={diff}"
);
}
}