pub fn get_recommended_allocator() -> (AllocatorType, String)Expand description
Get recommended allocator for current runtime environment
Based on current system hardware and environment re-analysis, returns recommended allocator type and selection reason.
Unlike get_allocator_info(), this function re-performs hardware detection and analysis every time.
§Return Value
Returns a tuple (AllocatorType, String):
- First element: recommended allocator type
- Second element: recommendation reason, including hardware information
§Usage
This function is mainly used for:
- Performance analysis and optimization recommendations
- Verifying if current allocator selection is optimal
- Re-evaluation after runtime environment changes
§Examples
use auto_allocator;
let (recommended_type, reason) = auto_allocator::get_recommended_allocator();
println!("Recommended allocator: {:?}", recommended_type);
println!("Recommendation reason: {}", reason);
// Compare with current allocator
let current_type = auto_allocator::get_allocator_type();
if current_type == recommended_type {
println!("Current allocator is already optimal");
} else {
println!("Suggest switching to: {:?}", recommended_type);
}§Performance Notes
This function re-performs system hardware detection, with slightly higher overhead than get_allocator_info().