voelinctl stream bench; a desktop-like test pattern

`voelinctl stream bench [--res WxH] [--fps N] [--codec vp8|vp9|h264]
[--layer SPEC ...] [--seconds N]` runs the streamer's real pipeline on the
test pattern without a server, into a sink that counts frames, keyframes
and bytes per layer, and prints frame and bit rates, CPU use and heap
allocations per frame in the steady state. Allocations are counted by a
global allocator in voelinctl only (one relaxed atomic add each).

The flat test pattern costs an encoder next to nothing, so it cannot show
how the pipeline copes with real screens. `Pattern::Desktop` looks like a
desktop with a code editor (gradient title bar, side bar, coloured lines
of text) whose document scrolls three pixels per frame; it is rendered
once and copied per frame, so drawing it stays cheap. The bench uses it by
default (`--pattern simple` for the old one); `StreamerConfig` gets
`synthetic_pattern`. Drawing the pattern now reuses a buffer
(`SyntheticScreen::render`) and fills rows by copying.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
Claude committed 2026-09-26 23:37:11 +00:00
1 parent 1182cd98e1
commit 31b138adf1
5 files changed
+645 -34

No files matched your search

+5 -2
View File
@@ -32,7 +32,7 @@ use std::time::{Duration, Instant};
use tracing::{debug, warn};
use voelin_audio::{VoiceCodec, VoiceEncoder};
pub use voelin_media;
use voelin_media::capture::synthetic::{SineSource, SyntheticScreen};
use voelin_media::capture::synthetic::{Pattern, SineSource, SyntheticScreen};
use voelin_media::capture::{
self, AudioCapture, CaptureOptions, CaptureSource, ScreenCapture, SourceId,
};
@@ -202,6 +202,8 @@ pub struct StreamerConfig {
pub cursor: bool,
/// Size of the test pattern ([`SourceId::Synthetic`]).
pub synthetic_size: (u32, u32),
/// What the test pattern shows.
pub synthetic_pattern: Pattern,
/// Portal restore token from an earlier share: the desktop may skip its
/// dialog. The new one is [`Streamer::restore_token`].
pub restore_token: Option<String>,
@@ -220,6 +222,7 @@ impl Default for StreamerConfig {
audio: true,
cursor: true,
synthetic_size: (1280, 720),
synthetic_pattern: Pattern::Simple,
restore_token: None,
layers: Vec::new(),
}
@@ -296,7 +299,7 @@ impl Streamer {
let (screen, frames, restore_token): (Box<dyn ScreenCapture>, _, _) = match &config.source {
SourceId::Synthetic => {
let (w, h) = config.synthetic_size;
let mut screen = SyntheticScreen::new(w, h);
let mut screen = SyntheticScreen::with_pattern(w, h, config.synthetic_pattern);
let frames = screen.start(&SourceId::Synthetic, &options).await?;
(Box::new(screen), frames, None)
}