Two fixes surfaced by run #55: 1. veza-stream-server (47 files): cargo fmt had been run locally but never committed — the working tree was clean locally while HEAD had unformatted code. CI's `cargo fmt -- --check` caught the drift. This commit lands the formatting that was already staged. 2. ci.yml Install Go tools: `go install .../cmd/golangci-lint@latest` resolves to v1.64.8 (the old /cmd/ module path). The repo's .golangci.yml is v2-format, so v1 refuses with: "you are using a configuration file for golangci-lint v2 with golangci-lint v1: please use golangci-lint v2" Switch to the /v2/cmd/ path so @latest actually gets v2.x.
37 lines
1 KiB
Rust
37 lines
1 KiB
Rust
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
|
use std::str::FromStr;
|
|
use stream_server::streaming::protocols::http_range::ByteRange;
|
|
|
|
fn bench_parse_range(c: &mut Criterion) {
|
|
c.bench_function("parse_exact_range", |b| {
|
|
b.iter(|| {
|
|
ByteRange::from_str(black_box("bytes=0-499")).unwrap();
|
|
})
|
|
});
|
|
|
|
c.bench_function("parse_suffix_range", |b| {
|
|
b.iter(|| {
|
|
ByteRange::from_str(black_box("bytes=-500")).unwrap();
|
|
})
|
|
});
|
|
|
|
c.bench_function("parse_from_range", |b| {
|
|
b.iter(|| {
|
|
ByteRange::from_str(black_box("bytes=1000-")).unwrap();
|
|
})
|
|
});
|
|
}
|
|
|
|
fn bench_resolve_range(c: &mut Criterion) {
|
|
let range = ByteRange::Exact(1000, 2000);
|
|
let file_size = 5000;
|
|
|
|
c.bench_function("resolve_range", |b| {
|
|
b.iter(|| {
|
|
range.resolve(black_box(file_size)).unwrap();
|
|
})
|
|
});
|
|
}
|
|
|
|
criterion_group!(benches, bench_parse_range, bench_resolve_range);
|
|
criterion_main!(benches);
|