memory: include total rounded to nearest integer
This commit is contained in:
parent
25cd2dcfe8
commit
c57cd52e84
1 changed files with 4 additions and 5 deletions
|
@ -29,12 +29,11 @@ pub fn getJson(module: *const Module) !Module.JSON {
|
|||
_ = mem_total_split.next();
|
||||
_ = mem_available_split.next();
|
||||
|
||||
const mem_total = try std.fmt.parseInt(usize, mem_total_split.next().?, 10);
|
||||
const mem_available = try std.fmt.parseInt(usize, mem_available_split.next().?, 10);
|
||||
|
||||
const mem = @as(f32, @floatFromInt(mem_total)) - @as(f32, @floatFromInt(mem_available));
|
||||
const mem_total: f32 = @floatFromInt(try std.fmt.parseInt(usize, mem_total_split.next().?, 10));
|
||||
const mem_available: f32 = @floatFromInt(try std.fmt.parseInt(usize, mem_available_split.next().?, 10));
|
||||
const mem = mem_total - mem_available;
|
||||
|
||||
return .{
|
||||
.full_text = try std.fmt.allocPrint(self.module.allocator, "{d:.3} GB", .{mem / 1000 / 1000}),
|
||||
.full_text = try std.fmt.allocPrint(self.module.allocator, "{d:.3}/{d:.0} GB", .{ mem / 1000 / 1000, mem_total / 1000 / 1000 }),
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue