mirror of
https://codeberg.org/icewind/vmdl.git
synced 2026-06-03 16:44:11 +02:00
benches
This commit is contained in:
parent
28d8f5dee5
commit
526efa83dc
3 changed files with 56 additions and 1 deletions
11
Cargo.toml
11
Cargo.toml
|
|
@ -12,7 +12,18 @@ static_assertions = "1.1.0"
|
||||||
bitflags = "1.0.4"
|
bitflags = "1.0.4"
|
||||||
itertools = "0.10.3"
|
itertools = "0.10.3"
|
||||||
tracing = "0.1.29"
|
tracing = "0.1.29"
|
||||||
|
bytemuck = { version = "1.8.0", features = ["derive"] }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
three-d = "0.10.2"
|
three-d = "0.10.2"
|
||||||
miette = { version = "4.2.1", features = ["fancy"] }
|
miette = { version = "4.2.1", features = ["fancy"] }
|
||||||
|
criterion = "0.3"
|
||||||
|
iai = "0.1"
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "parse"
|
||||||
|
harness = false
|
||||||
|
|
||||||
|
[[bench]]
|
||||||
|
name = "iai"
|
||||||
|
harness = false
|
||||||
21
benches/iai.rs
Normal file
21
benches/iai.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
use iai::black_box;
|
||||||
|
use vmdl::mdl::Mdl;
|
||||||
|
use vmdl::vtx::Vtx;
|
||||||
|
use vmdl::vvd::Vvd;
|
||||||
|
|
||||||
|
fn parse_mdl() {
|
||||||
|
let data = include_bytes!("../data/barrel01.mdl");
|
||||||
|
Mdl::read(black_box(data)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_vtx() {
|
||||||
|
let data = include_bytes!("../data/barrel01.dx90.vtx");
|
||||||
|
Vtx::read(black_box(data)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_vvd() {
|
||||||
|
let data = include_bytes!("../data/barrel01.vvd");
|
||||||
|
Vvd::read(black_box(data)).unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
|
iai::main!(parse_mdl, parse_vtx, parse_vvd);
|
||||||
23
benches/parse.rs
Normal file
23
benches/parse.rs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
use criterion::{black_box, criterion_group, criterion_main, Criterion};
|
||||||
|
use std::fs::read;
|
||||||
|
use vmdl::mdl::Mdl;
|
||||||
|
use vmdl::vtx::Vtx;
|
||||||
|
use vmdl::vvd::Vvd;
|
||||||
|
|
||||||
|
fn parse_mdl(c: &mut Criterion) {
|
||||||
|
let data = read("data/barrel01.mdl").unwrap();
|
||||||
|
c.bench_function("mdl", |b| b.iter(|| Mdl::read(black_box(&data)).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_vtx(c: &mut Criterion) {
|
||||||
|
let data = read("data/barrel01.dx90.vtx").unwrap();
|
||||||
|
c.bench_function("vtx", |b| b.iter(|| Vtx::read(black_box(&data)).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
fn parse_vvd(c: &mut Criterion) {
|
||||||
|
let data = read("data/barrel01.vvd").unwrap();
|
||||||
|
c.bench_function("vvd", |b| b.iter(|| Vvd::read(black_box(&data)).unwrap()));
|
||||||
|
}
|
||||||
|
|
||||||
|
criterion_group!(benches, parse_mdl, parse_vtx, parse_vvd);
|
||||||
|
criterion_main!(benches);
|
||||||
Loading…
Add table
Add a link
Reference in a new issue