pub async fn get_performance_tier() -> Result<String, String>Expand description
Used to get an understanding of device power
The function gets various system information (see below) and then calculates a score which returns “high”, “medium” or “low”. This function has many uses but is ideal for tweaking settings or interal things to operate on the user’s device more effeciently.
This is dynamic in a way that, if a “high” rated device has low system resources available (such that a heavy operation could cause the device to freeze or “lag”), this function will not return “high” even though the device is capable of it. This is to ensure that the user has a good experience and does not have to deal with a “laggy” application due to quantity of resouces.
Below is what system information this function looks at
- CPU Core count
- CPU frequency in MHz
- Total RAM/memory
- Used RAM/memory
- System load (1-minute average)
§returns
- “high” if the device is capable of running heavy operations without lagging
- “medium” if the device is capable of running medium operations without lagging
- “low” if the device is not capable of running medium or heavy operations without lagging
§Example
let performance_tier = get_performance_tier().await.unwrap();
assert!(performance_tier == "high" || performance_tier == "medium" || performance_tier == "low");