Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 116 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ indexmap = { version = "2.13", features = ["serde"] }

opentelemetry = "0.31.0"

criterion = { version = "0.5", default-features = false }

# Profile settings
[profile.release]
debug = 1 # Include line tables for better stack traces in profiling
Expand Down
2 changes: 2 additions & 0 deletions crates/engine/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords = ["audio", "pipeline", "engine", "streaming", "realtime"]
categories = ["multimedia", "network-programming"]
readme = "README.md"
publish = false
autobenches = false

[dependencies]
# Skit's core library
Expand Down Expand Up @@ -56,6 +57,7 @@ script = ["streamkit-nodes/script"]
compositor = ["streamkit-nodes/compositor"]

[dev-dependencies]
criterion = { workspace = true }
serde_json = { workspace = true }
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
futures = { workspace = true }
Expand Down
72 changes: 72 additions & 0 deletions crates/engine/benches/bench_utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// SPDX-FileCopyrightText: © 2025 StreamKit Contributors
//
// SPDX-License-Identifier: MPL-2.0

//! Shared utilities for benchmark binaries.

#![allow(dead_code)] // Not every bench uses every helper.

use streamkit_nodes::video::pixel_ops::{rgba8_to_i420_buf, rgba8_to_nv12_buf};

/// Standard resolutions used across benchmark suites.
pub const RESOLUTIONS: &[(u32, u32)] = &[(640, 480), (1280, 720), (1920, 1080)];

/// Generate an RGBA8 color-bar frame (opaque, all alpha = 255).
#[allow(
clippy::many_single_char_names,
clippy::cast_possible_truncation,
clippy::cast_sign_loss,
clippy::cast_precision_loss
)]
pub fn generate_rgba_frame(width: u32, height: u32) -> Vec<u8> {
let w = width as usize;
let h = height as usize;
let mut data = vec![0u8; w * h * 4];
let bar_colors: &[(u8, u8, u8)] = &[
(191, 191, 191), // white
(191, 191, 0), // yellow
(0, 191, 191), // cyan
(0, 191, 0), // green
(191, 0, 191), // magenta
(191, 0, 0), // red
(0, 0, 191), // blue
];
for row in 0..h {
for col in 0..w {
let bar_idx = col * bar_colors.len() / w;
let (r, g, b) = bar_colors[bar_idx];
let off = (row * w + col) * 4;
data[off] = r;
data[off + 1] = g;
data[off + 2] = b;
data[off + 3] = 255;
}
}
data
}

/// Generate an I420 frame by converting an RGBA frame.
pub fn generate_i420_frame(width: u32, height: u32) -> Vec<u8> {
let rgba = generate_rgba_frame(width, height);
let w = width as usize;
let h = height as usize;
let chroma_w = w.div_ceil(2);
let chroma_h = h.div_ceil(2);
let i420_size = w * h + 2 * chroma_w * chroma_h;
let mut i420 = vec![0u8; i420_size];
rgba8_to_i420_buf(&rgba, width, height, &mut i420);
i420
}

/// Generate an NV12 frame by converting an RGBA frame.
pub fn generate_nv12_frame(width: u32, height: u32) -> Vec<u8> {
let rgba = generate_rgba_frame(width, height);
let w = width as usize;
let h = height as usize;
let chroma_w = w.div_ceil(2);
let chroma_h = h.div_ceil(2);
let nv12_size = w * h + chroma_w * 2 * chroma_h;
let mut nv12 = vec![0u8; nv12_size];
rgba8_to_nv12_buf(&rgba, width, height, &mut nv12);
nv12
}
Loading