PDE Module Performance Report
Comprehensive performance benchmarks for the MathHook PDE module, establishing baseline metrics for regression detection and optimization efforts. Includes 8 benchmarks covering critical operations from coefficient extraction to numerical integration, with detailed scalability analysis and optimization recommendations.
ð
Mathematical Definition
Performance characteristics of key operations:
Coefficient Extraction:
- constant-time for simplified coefficients
ODE System Construction:
- fixed three equations
Numerical Integration:
where
= interval length,
= step size
Memory Overhead: Expression size = 32 bytes, Number size = 16 bytes (hard constraints)
Code Examples
Benchmark Execution
Run comprehensive benchmark suite
// Run all PDE benchmarks
cargo bench --bench pde_benchmarks
// Run specific benchmark
cargo bench --bench pde_benchmarks -- pde_coefficient_extraction
// Save baseline for future comparison
cargo bench --bench pde_benchmarks -- --save-baseline main
Memory Profiling
Profile memory allocations during PDE solving
use dhat::{Dhat, DhatAlloc};
#[global_allocator]
static ALLOCATOR: DhatAlloc = DhatAlloc;
fn main() {
let _dhat = Dhat::start_heap_profiling();
// Your PDE solving code
let pde = Pde::new(equation, u, vec![x, t]);
let solution = method_of_characteristics(&pde);
// Memory statistics printed on drop
}
Performance Comparison
Compare MathHook performance against SymPy
use criterion::{black_box, criterion_group, criterion_main, Criterion};
fn benchmark_mathhook_vs_sympy(c: &mut Criterion) {
let mut group = c.benchmark_group("mathhook_vs_sympy");
// MathHook benchmark
group.bench_function("mathhook_transport", |b| {
b.iter(|| {
let pde = Pde::new(black_box(equation), u, vec![x, t]);
method_of_characteristics(&pde)
});
});
// SymPy benchmark (via Python binding)
group.bench_function("sympy_transport", |b| {
b.iter(|| {
sympy_solve_transport(black_box(&equation))
});
});
group.finish();
}
criterion_group!(benches, benchmark_mathhook_vs_sympy);
criterion_main!(benches);