use memkit::{MkAllocator, MkConfig};
use std::time::Duration;
fn main() {
let alloc = MkAllocator::new(MkConfig::default());
println!("Starting multi-phase frame demonstration...");
alloc.begin_frame();
{
let _phase = alloc.begin_phase("Physics");
println!("Running Physics...");
let _ = alloc.frame_vec::<[f32; 3]>(1000).unwrap();
std::thread::sleep(Duration::from_millis(16));
}
{
let phase = alloc.begin_phase("AI");
println!("Running AI...");
let _ = alloc.frame_box(42).unwrap();
std::thread::sleep(Duration::from_millis(8));
let report = phase.end();
println!("Phase '{}' took {:?} with {} allocations ({} bytes)",
report.name, report.duration, report.alloc_count, report.bytes_allocated);
}
{
let _phase = alloc.begin_phase("Rendering");
println!("Running Rendering...");
let _ = alloc.frame_slice::<u8>(1024 * 1024).unwrap();
std::thread::sleep(Duration::from_millis(4));
}
alloc.end_frame();
let stats = alloc.stats();
println!("Total frame allocations: {} ({} bytes)", stats.allocation_count, stats.total_allocated);
}