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

34
Cargo.lock generated
View file

@ -2757,6 +2757,12 @@ version = "1.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421"
[[package]]
name = "human_bytes"
version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39b528196c838e8b3da8b665e08c30958a6f2ede91d79f2ffcd0d4664b9c64eb"
[[package]] [[package]]
name = "humantime" name = "humantime"
version = "2.1.0" version = "2.1.0"
@ -3755,6 +3761,15 @@ dependencies = [
"winapi 0.3.9", "winapi 0.3.9",
] ]
[[package]]
name = "ntapi"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc"
dependencies = [
"winapi 0.3.9",
]
[[package]] [[package]]
name = "nu-ansi-term" name = "nu-ansi-term"
version = "0.46.0" version = "0.46.0"
@ -4424,7 +4439,7 @@ source = "git+https://github.com/zed-industries/wezterm?rev=5cd757e5f2eb039ed0c6
dependencies = [ dependencies = [
"libc", "libc",
"log", "log",
"ntapi", "ntapi 0.3.7",
"winapi 0.3.9", "winapi 0.3.9",
] ]
@ -6219,6 +6234,21 @@ dependencies = [
"libc", "libc",
] ]
[[package]]
name = "sysinfo"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccb297c0afb439440834b4bcf02c5c9da8ec2e808e70f36b0d8e815ff403bd24"
dependencies = [
"cfg-if 1.0.0",
"core-foundation-sys",
"libc",
"ntapi 0.4.0",
"once_cell",
"rayon",
"winapi 0.3.9",
]
[[package]] [[package]]
name = "system-interface" name = "system-interface"
version = "0.20.0" version = "0.20.0"
@ -8180,6 +8210,7 @@ dependencies = [
"fuzzy", "fuzzy",
"go_to_line", "go_to_line",
"gpui", "gpui",
"human_bytes",
"ignore", "ignore",
"image", "image",
"indexmap", "indexmap",
@ -8213,6 +8244,7 @@ dependencies = [
"smallvec", "smallvec",
"smol", "smol",
"sum_tree", "sum_tree",
"sysinfo",
"tempdir", "tempdir",
"terminal_view", "terminal_view",
"text", "text",

View file

@ -30,6 +30,7 @@ clock = { path = "../clock" }
diagnostics = { path = "../diagnostics" } diagnostics = { path = "../diagnostics" }
editor = { path = "../editor" } editor = { path = "../editor" }
file_finder = { path = "../file_finder" } file_finder = { path = "../file_finder" }
human_bytes = "0.4.1"
search = { path = "../search" } search = { path = "../search" }
fs = { path = "../fs" } fs = { path = "../fs" }
fsevent = { path = "../fsevent" } fsevent = { path = "../fsevent" }
@ -48,6 +49,7 @@ recent_projects = { path = "../recent_projects" }
rpc = { path = "../rpc" } rpc = { path = "../rpc" }
settings = { path = "../settings" } settings = { path = "../settings" }
sum_tree = { path = "../sum_tree" } sum_tree = { path = "../sum_tree" }
sysinfo = "0.27.1"
text = { path = "../text" } text = { path = "../text" }
terminal_view = { path = "../terminal_view" } terminal_view = { path = "../terminal_view" }
theme = { path = "../theme" } theme = { path = "../theme" }

View file

@ -1,28 +1,33 @@
use std::{env, fmt::Display}; use std::{env, fmt::Display};
use gpui::AppContext; use gpui::AppContext;
use human_bytes::human_bytes;
use sysinfo::{System, SystemExt};
use util::channel::ReleaseChannel; use util::channel::ReleaseChannel;
pub struct SystemSpecs { pub struct SystemSpecs {
os_name: &'static str,
os_version: Option<String>,
app_version: &'static str, app_version: &'static str,
release_channel: &'static str, release_channel: &'static str,
os_name: &'static str,
os_version: Option<String>,
memory: u64,
architecture: &'static str, architecture: &'static str,
} }
impl SystemSpecs { impl SystemSpecs {
pub fn new(cx: &AppContext) -> Self { pub fn new(cx: &AppContext) -> Self {
let platform = cx.platform(); let platform = cx.platform();
let system = System::new_all();
SystemSpecs { SystemSpecs {
app_version: env!("CARGO_PKG_VERSION"),
release_channel: cx.global::<ReleaseChannel>().dev_name(),
os_name: platform.os_name(), os_name: platform.os_name(),
os_version: platform os_version: platform
.os_version() .os_version()
.ok() .ok()
.map(|os_version| os_version.to_string()), .map(|os_version| os_version.to_string()),
app_version: env!("CARGO_PKG_VERSION"), memory: system.total_memory(),
release_channel: cx.global::<ReleaseChannel>().dev_name(),
architecture: env::consts::ARCH, architecture: env::consts::ARCH,
} }
} }
@ -35,8 +40,9 @@ impl Display for SystemSpecs {
None => format!("OS: {}", self.os_name), None => format!("OS: {}", self.os_name),
}; };
let system_specs = [ let system_specs = [
os_information,
format!("Zed: {} ({})", self.app_version, self.release_channel), format!("Zed: {} ({})", self.app_version, self.release_channel),
os_information,
format!("Memory: {}", human_bytes(self.memory as f64)),
format!("Architecture: {}", self.architecture), format!("Architecture: {}", self.architecture),
] ]
.join("\n"); .join("\n");