Skip to content

Commit

Permalink
Added small piece of code to inspect heap allocations
Browse files Browse the repository at this point in the history
  • Loading branch information
gammelalf committed Sep 27, 2022
1 parent 606606e commit 795e5f4
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions examples/heaptrack.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
use nbezier::nbezier::BezierCurve;
use nalgebra::{Matrix2x4, Matrix2xX};
use criterion::black_box;

#[global_allocator]
static ALLOC: dhat::Alloc = dhat::Alloc;

fn main() {
let profiler = dhat::Profiler::new_heap();
let curve = BezierCurve(Matrix2x4::new(
50.0, 200.0, 0.0, 50.0, 0.0, 33.0, 66.0, 100.0
));
black_box(curve.split(0.5));
black_box(curve.castlejau_eval(0.5));
black_box(curve);
drop(profiler);

let profiler = dhat::Profiler::new_heap();
let curve = BezierCurve(Matrix2xX::from_iterator(4,
[50.0, 200.0, 0.0, 50.0, 0.0, 33.0, 66.0, 100.0]
));
black_box(curve.split(0.5));
black_box(curve.castlejau_eval(0.5));
black_box(curve);
drop(profiler);
}

0 comments on commit 795e5f4

Please sign in to comment.