-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
559 additions
and
113 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
[package] | ||
name = "simd_test" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
breakwater = { path = "../" } | ||
|
||
# chrono = "0.4" | ||
# clap = { version = "4.3", features = ["derive"] } | ||
# const_format = "0.2" | ||
# env_logger = "0.10" | ||
# lazy_static = "1.4" | ||
# log = "0.4" | ||
# number_prefix = "0.4" | ||
# prometheus_exporter = "0.8" | ||
# rusttype = "0.9" | ||
# serde = { version = "1.0", features = ["derive"] } | ||
# serde_json = "1.0" | ||
# simple_moving_average = "0.1" | ||
# thread-priority = "0.13" | ||
tokio = { version = "1.29", features = ["fs", "rt-multi-thread", "net", "io-util", "macros", "process", "signal", "sync", "time"] } | ||
# vncserver = { version ="0.2", optional = true} | ||
|
||
[dev-dependencies] | ||
criterion = {version = "0.5", features = ["async_tokio"]} | ||
pixelbomber = "0.4.1" | ||
# rstest = "0.18" | ||
# rand = "0.8" | ||
|
||
[lib] | ||
name = "simd_test" | ||
path = "src/lib.rs" | ||
|
||
[[bench]] | ||
name = "benchmarks" | ||
harness = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,162 @@ | ||
#![feature(portable_simd)] | ||
|
||
use breakwater::{framebuffer::FrameBuffer, parser::ParserState, test::helpers::DevNullTcpStream}; | ||
use criterion::{ | ||
BenchmarkId, Criterion, {criterion_group, criterion_main}, | ||
}; | ||
use pixelbomber::image_handler; | ||
use pixelbomber::image_handler::ImageConfig; | ||
use std::{sync::Arc, time::Duration}; | ||
|
||
const FRAMEBUFFER_WIDTH: usize = 1920; | ||
const FRAMEBUFFER_HEIGHT: usize = 1080; | ||
|
||
async fn invoke_parse_pixelflut_commands_base( | ||
input: &[u8], | ||
fb: &Arc<FrameBuffer>, | ||
parser_state: ParserState, | ||
) { | ||
let mut stream = DevNullTcpStream::default(); | ||
breakwater::parser::parse_pixelflut_commands(input, fb, &mut stream, parser_state).await; | ||
} | ||
|
||
async fn invoke_parse_pixelflut_commands_simd( | ||
input: &[u8], | ||
fb: &Arc<FrameBuffer>, | ||
parser_state: ParserState, | ||
) { | ||
let mut stream = DevNullTcpStream::default(); | ||
simd_test::parser::parse_pixelflut_commands(input, fb, &mut stream, parser_state).await; | ||
} | ||
|
||
fn benchmark_base(c: &mut Criterion, name: &str, file: &str, config: ImageConfig) { | ||
let mut commands = image_handler::load(vec![file], &config); | ||
let command = commands.pop().unwrap(); | ||
c.bench_with_input( | ||
BenchmarkId::new(name, format!("{FRAMEBUFFER_WIDTH} x {FRAMEBUFFER_HEIGHT}")), | ||
&command, | ||
|b, input| { | ||
let fb = Arc::new(FrameBuffer::new(FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT)); | ||
let parser_state = ParserState::default(); | ||
b.to_async(tokio::runtime::Runtime::new().unwrap()) | ||
.iter(|| invoke_parse_pixelflut_commands_base(input, &fb, parser_state.clone())); | ||
}, | ||
); | ||
} | ||
|
||
fn benchmark_simd(c: &mut Criterion, name: &str, file: &str, config: ImageConfig) { | ||
let mut commands = image_handler::load(vec![file], &config); | ||
let command = commands.pop().unwrap(); | ||
c.bench_with_input( | ||
BenchmarkId::new(name, format!("{FRAMEBUFFER_WIDTH} x {FRAMEBUFFER_HEIGHT}")), | ||
&command, | ||
|b, input| { | ||
let fb = Arc::new(FrameBuffer::new(FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT)); | ||
let parser_state = ParserState::default(); | ||
b.to_async(tokio::runtime::Runtime::new().unwrap()) | ||
.iter(|| invoke_parse_pixelflut_commands_simd(input, &fb, parser_state.clone())); | ||
}, | ||
); | ||
} | ||
|
||
fn add_benches(c: &mut Criterion) { | ||
// benchmark_base( | ||
// c, | ||
// "parse_draw_commands_ordered", | ||
// "benches/non-transparent.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .build(), | ||
// ); | ||
|
||
benchmark_base( | ||
c, | ||
"base_parse_draw_commands_shuffled", | ||
"benches/non-transparent.png", | ||
image_handler::ImageConfigBuilder::new() | ||
.width(FRAMEBUFFER_WIDTH as u32) | ||
.height(FRAMEBUFFER_HEIGHT as u32) | ||
.shuffle(true) | ||
.build(), | ||
); | ||
|
||
// benchmark_base( | ||
// c, | ||
// "parse_mixed_draw_commands", | ||
// "benches/mixed.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .gray_usage(true) | ||
// .build(), | ||
// ); | ||
|
||
// benchmark_base( | ||
// c, | ||
// "parse_draw_commands_with_offset", | ||
// "benches/non-transparent.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .offset_usage(true) | ||
// .build(), | ||
// ); | ||
|
||
// benchmark_simd( | ||
// c, | ||
// "parse_draw_commands_ordered", | ||
// "benches/non-transparent.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .build(), | ||
// ); | ||
|
||
benchmark_simd( | ||
c, | ||
"simd_parse_draw_commands_shuffled", | ||
"benches/non-transparent.png", | ||
image_handler::ImageConfigBuilder::new() | ||
.width(FRAMEBUFFER_WIDTH as u32) | ||
.height(FRAMEBUFFER_HEIGHT as u32) | ||
.shuffle(true) | ||
.build(), | ||
); | ||
|
||
// benchmark_simd( | ||
// c, | ||
// "parse_mixed_draw_commands", | ||
// "benches/mixed.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .gray_usage(true) | ||
// .build(), | ||
// ); | ||
|
||
// benchmark_simd( | ||
// c, | ||
// "parse_draw_commands_with_offset", | ||
// "benches/non-transparent.png", | ||
// image_handler::ImageConfigBuilder::new() | ||
// .width(FRAMEBUFFER_WIDTH as u32) | ||
// .height(FRAMEBUFFER_HEIGHT as u32) | ||
// .shuffle(false) | ||
// .offset_usage(true) | ||
// .build(), | ||
// ); | ||
} | ||
|
||
criterion_group!( | ||
name = benches; | ||
config = Criterion::default().warm_up_time(Duration::from_secs(2)).measurement_time(Duration::from_secs(3)); | ||
targets = add_benches, | ||
); | ||
|
||
criterion_main!(benches); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#![feature(portable_simd)] | ||
|
||
pub mod parser; |
Oops, something went wrong.