feat(macos): add ram usage percentage
This commit is contained in:
@@ -26,6 +26,7 @@ pub const GpuInfo = struct {
|
||||
pub const RamInfo = struct {
|
||||
ram_size: f64,
|
||||
ram_usage: f64,
|
||||
ram_usage_percentage: u8,
|
||||
};
|
||||
|
||||
/// Returns the current logged-in uesr's username.
|
||||
@@ -217,6 +218,7 @@ pub fn getRamInfo() !RamInfo {
|
||||
var ram_info = RamInfo{
|
||||
.ram_size = 0,
|
||||
.ram_usage = 0,
|
||||
.ram_usage_percentage = 0,
|
||||
};
|
||||
|
||||
// -- RAM SIZE --
|
||||
@@ -249,5 +251,8 @@ pub fn getRamInfo() !RamInfo {
|
||||
|
||||
ram_info.ram_usage = ram_usage_gb;
|
||||
|
||||
const ram_usage_percentage: u8 = @as(u8, @intFromFloat(@round((ram_usage_gb * 100) / ram_size_gb)));
|
||||
ram_info.ram_usage_percentage = ram_usage_percentage;
|
||||
|
||||
return ram_info;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user