Add memory to system specs

This commit is contained in:
Joseph Lyons
2022-12-22 18:10:49 -05:00
parent 96ac650465
commit f65fda2fa4
3 changed files with 46 additions and 6 deletions
+2
View File
@@ -30,6 +30,7 @@ clock = { path = "../clock" }
diagnostics = { path = "../diagnostics" }
editor = { path = "../editor" }
file_finder = { path = "../file_finder" }
human_bytes = "0.4.1"
search = { path = "../search" }
fs = { path = "../fs" }
fsevent = { path = "../fsevent" }
@@ -48,6 +49,7 @@ recent_projects = { path = "../recent_projects" }
rpc = { path = "../rpc" }
settings = { path = "../settings" }
sum_tree = { path = "../sum_tree" }
sysinfo = "0.27.1"
text = { path = "../text" }
terminal_view = { path = "../terminal_view" }
theme = { path = "../theme" }
+11 -5
View File
@@ -1,28 +1,33 @@
use std::{env, fmt::Display};
use gpui::AppContext;
use human_bytes::human_bytes;
use sysinfo::{System, SystemExt};
use util::channel::ReleaseChannel;
pub struct SystemSpecs {
os_name: &'static str,
os_version: Option<String>,
app_version: &'static str,
release_channel: &'static str,
os_name: &'static str,
os_version: Option<String>,
memory: u64,
architecture: &'static str,
}
impl SystemSpecs {
pub fn new(cx: &AppContext) -> Self {
let platform = cx.platform();
let system = System::new_all();
SystemSpecs {
app_version: env!("CARGO_PKG_VERSION"),
release_channel: cx.global::<ReleaseChannel>().dev_name(),
os_name: platform.os_name(),
os_version: platform
.os_version()
.ok()
.map(|os_version| os_version.to_string()),
app_version: env!("CARGO_PKG_VERSION"),
release_channel: cx.global::<ReleaseChannel>().dev_name(),
memory: system.total_memory(),
architecture: env::consts::ARCH,
}
}
@@ -35,8 +40,9 @@ impl Display for SystemSpecs {
None => format!("OS: {}", self.os_name),
};
let system_specs = [
os_information,
format!("Zed: {} ({})", self.app_version, self.release_channel),
os_information,
format!("Memory: {}", human_bytes(self.memory as f64)),
format!("Architecture: {}", self.architecture),
]
.join("\n");