Skip to content

Commit

Permalink
Fix benchmarks and add fill_yuv to benchmarks.
Browse files Browse the repository at this point in the history
  • Loading branch information
H-M-H committed Jun 11, 2020
1 parent d388579 commit 99da4b7
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,18 @@ mod tests {
#[bench]
fn bench_capture_x11(b: &mut Bencher) {
let mut x11ctx = x11helper::X11Context::new().unwrap();
let root = x11ctx.root_window();
let mut sc = screen_capture::linux::ScreenCaptureX11::new(root).unwrap();
let root = x11ctx.capturables().unwrap()[0].clone();
let mut sc = screen_capture::linux::ScreenCaptureX11::new(root, false).unwrap();
b.iter(|| sc.capture());
}

#[cfg(target_os = "linux")]
#[bench]
fn bench_video_x11(b: &mut Bencher) {
let mut x11ctx = x11helper::X11Context::new().unwrap();
let root = x11ctx.root_window();
let root = x11ctx.capturables().unwrap()[0].clone();
use screen_capture::ScreenCapture;
let mut sc = screen_capture::linux::ScreenCaptureX11::new(root).unwrap();
let mut sc = screen_capture::linux::ScreenCaptureX11::new(root, false).unwrap();
sc.capture();
let (width, height) = sc.size();

Expand All @@ -115,4 +115,19 @@ mod tests {
})
});
}

#[cfg(target_os = "linux")]
#[bench]
fn bench_fill_yuv_x11(b: &mut Bencher) {
let mut x11ctx = x11helper::X11Context::new().unwrap();
let root = x11ctx.capturables().unwrap()[0].clone();
use screen_capture::ScreenCapture;
let mut sc = screen_capture::linux::ScreenCaptureX11::new(root, false).unwrap();
sc.capture();
let (width, height) = sc.size();
let mut y = vec![0u8; width * height];
let mut u = vec![0u8; width * height / 2];
let mut v = vec![0u8; width * height / 2];
b.iter(|| sc.fill_yuv(&mut y, &mut u, &mut v, width, width/2, width/2));
}
}

0 comments on commit 99da4b7

Please sign in to comment.