auto-allocator 0.1.0

Zero-configuration automatic memory allocator selection based on runtime hardware analysis and performance research
Documentation
/// ๐Ÿš€ Auto-Allocator Basic Usage Demo
///
/// This example demonstrates the core functionality of auto-allocator:
/// 1. ๐ŸŽฏ Zero-configuration automatic allocator selection
/// 2. ๐Ÿ“Š System information viewing
/// 3. โš™๏ธ Environment variable control methods
/// 4. ๐Ÿงช Basic memory allocation testing

// This is the core usage of auto-allocator: just one use statement enables automatic allocator selection
#[allow(clippy::single_component_path_imports)]
use auto_allocator;

fn main() {
    // Initialize logging (skip on WASM)
    #[cfg(not(target_arch = "wasm32"))]
    env_logger::init();

    println!("๐Ÿš€ Auto Allocator Demo");
    println!("======================");

    // Get allocator information
    let info = auto_allocator::get_allocator_info();

    println!("โœ… Selected allocator: {:?}", info.allocator_type);
    println!("๐Ÿ“ Reason: {}", info.reason);
    println!();

    // Demonstrate automatic selection features
    println!("๐ŸŽฏ Runtime Hardware Selection:");
    println!("- Debug builds: automatically use system allocator");
    println!("- Release + modern platforms: automatically use mimalloc (best performance)");
    println!("- WASM/Mobile platforms: system allocator for compatibility");
    println!("- Embedded systems: specialized embedded allocator");
    println!();
    
    println!("๐Ÿ† Based on Microsoft and independent performance research:");
    println!("  โ€ข mimalloc provides superior multi-threaded performance");
    println!("  โ€ข Up to 1.6x faster than system allocators in complex workloads");
    println!("  โ€ข Better memory efficiency and cross-platform support");
    println!("๐Ÿ’ก This is pure runtime selection - no configuration needed!");
    println!();

    // Demonstrate basic memory allocation
    let data: Vec<u8> = (0..1000).map(|i| (i % 256) as u8).collect();
    println!(
        "โœ… Successfully allocated and populated Vec with {} bytes",
        data.len()
    );

    let text = "Hello, world!".repeat(100);
    println!("โœ… Successfully allocated String with {} bytes", text.len());

    println!();
    println!("๐Ÿ“Š System Information:");
    println!("  ๐Ÿ–ฅ๏ธ  OS: {}", info.system_info.os_type);
    println!("  โš™๏ธ  CPU Cores: {}", info.system_info.cpu_cores);
    println!(
        "  ๐Ÿง  Total Memory: {}",
        auto_allocator::format_memory_size(info.system_info.total_memory_bytes)
    );
    println!("  ๐ŸŒ WASM: {}", info.system_info.is_wasm);
    println!("  ๐Ÿ› Debug Build: {}", info.system_info.is_debug);
    println!("  ๐Ÿ—๏ธ  Architecture: {}", info.system_info.target_arch);
}