Skip to content

Commit

Permalink
Speed up function tests (#122)
Browse files Browse the repository at this point in the history
Previously, tests of the `Function` trait went through the `Shape`
interface and checked all combinations of X, Y, Z arguments. However,
X/Y/Z are simply variables now, so we don't need to be so exhaustive
(and speed up CI).
  • Loading branch information
mkeeter authored May 26, 2024
1 parent 652d5ad commit 72a1365
Show file tree
Hide file tree
Showing 18 changed files with 1,040 additions and 940 deletions.
12 changes: 6 additions & 6 deletions demo/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,12 +271,12 @@ fn main() -> Result<()> {
let buffer = match settings.eval {
#[cfg(feature = "jit")]
EvalMode::Jit => {
let shape = fidget::jit::JitShape::new(&mut ctx, root)?;
let shape = fidget::jit::JitShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run2d(shape, &settings, brute, sdf)
}
EvalMode::Vm => {
let shape = fidget::vm::VmShape::new(&mut ctx, root)?;
let shape = fidget::vm::VmShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run2d(shape, &settings, brute, sdf)
}
Expand Down Expand Up @@ -308,12 +308,12 @@ fn main() -> Result<()> {
let buffer = match settings.eval {
#[cfg(feature = "jit")]
EvalMode::Jit => {
let shape = fidget::jit::JitShape::new(&mut ctx, root)?;
let shape = fidget::jit::JitShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run3d(shape, &settings, isometric, color)
}
EvalMode::Vm => {
let shape = fidget::vm::VmShape::new(&mut ctx, root)?;
let shape = fidget::vm::VmShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run3d(shape, &settings, isometric, color)
}
Expand Down Expand Up @@ -342,12 +342,12 @@ fn main() -> Result<()> {
let mesh = match settings.eval {
#[cfg(feature = "jit")]
EvalMode::Jit => {
let shape = fidget::jit::JitShape::new(&mut ctx, root)?;
let shape = fidget::jit::JitShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run_mesh(shape, &settings)
}
EvalMode::Vm => {
let shape = fidget::vm::VmShape::new(&mut ctx, root)?;
let shape = fidget::vm::VmShape::new(&ctx, root)?;
info!("Built shape in {:?}", start.elapsed());
run_mesh(shape, &settings)
}
Expand Down
4 changes: 2 additions & 2 deletions fidget/benches/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ use fidget::{

pub fn run_bench<F: Function + MathFunction>(
c: &mut Criterion,
mut ctx: Context,
ctx: Context,
node: Node,
test_name: &'static str,
name: &'static str,
) {
let shape_vm = &Shape::<F>::new(&mut ctx, node).unwrap();
let shape_vm = &Shape::<F>::new(&ctx, node).unwrap();

let mut eval = Shape::<F>::new_float_slice_eval();
let tape = shape_vm.ez_float_slice_tape();
Expand Down
12 changes: 5 additions & 7 deletions fidget/benches/mesh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@ use criterion::{
const COLONNADE: &str = include_str!("../../models/colonnade.vm");

pub fn colonnade_octree_thread_sweep(c: &mut Criterion) {
let (mut ctx, root) =
fidget::Context::from_text(COLONNADE.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&mut ctx, root).unwrap();
let (ctx, root) = fidget::Context::from_text(COLONNADE.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&ctx, root).unwrap();
#[cfg(feature = "jit")]
let shape_jit = &fidget::jit::JitShape::new(&mut ctx, root).unwrap();
let shape_jit = &fidget::jit::JitShape::new(&ctx, root).unwrap();

let mut group =
c.benchmark_group("speed vs threads (colonnade, octree) (depth 6)");
Expand All @@ -36,9 +35,8 @@ pub fn colonnade_octree_thread_sweep(c: &mut Criterion) {
}

pub fn colonnade_mesh(c: &mut Criterion) {
let (mut ctx, root) =
fidget::Context::from_text(COLONNADE.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&mut ctx, root).unwrap();
let (ctx, root) = fidget::Context::from_text(COLONNADE.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&ctx, root).unwrap();
let cfg = fidget::mesh::Settings {
depth: 8,
..Default::default()
Expand Down
14 changes: 6 additions & 8 deletions fidget/benches/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@ use fidget::shape::RenderHints;
const PROSPERO: &str = include_str!("../../models/prospero.vm");

pub fn prospero_size_sweep(c: &mut Criterion) {
let (mut ctx, root) =
fidget::Context::from_text(PROSPERO.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&mut ctx, root).unwrap();
let (ctx, root) = fidget::Context::from_text(PROSPERO.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&ctx, root).unwrap();

#[cfg(feature = "jit")]
let shape_jit = &fidget::jit::JitShape::new(&mut ctx, root).unwrap();
let shape_jit = &fidget::jit::JitShape::new(&ctx, root).unwrap();

let mut group =
c.benchmark_group("speed vs image size (prospero, 2d) (8 threads)");
Expand Down Expand Up @@ -52,12 +51,11 @@ pub fn prospero_size_sweep(c: &mut Criterion) {
}

pub fn prospero_thread_sweep(c: &mut Criterion) {
let (mut ctx, root) =
fidget::Context::from_text(PROSPERO.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&mut ctx, root).unwrap();
let (ctx, root) = fidget::Context::from_text(PROSPERO.as_bytes()).unwrap();
let shape_vm = &fidget::vm::VmShape::new(&ctx, root).unwrap();

#[cfg(feature = "jit")]
let shape_jit = &fidget::jit::JitShape::new(&mut ctx, root).unwrap();
let shape_jit = &fidget::jit::JitShape::new(&ctx, root).unwrap();

let mut group =
c.benchmark_group("speed vs threads (prospero, 2d) (1024 x 1024)");
Expand Down
Loading

0 comments on commit 72a1365

Please sign in to comment.