mirror of
https://github.com/denoland/deno.git
synced 2024-12-29 02:29:06 -05:00
fix(ext/node): read correct CPU usage stats on Linux (#24732)
Fixes #24731 <img width="554" alt="deno_fixed" src="https://github.com/user-attachments/assets/691f2f89-d979-4ca5-be9a-cf51446cd9b2"> The total CPU usage row is ignored and info from `cpu0` and `cpu1` is correctly read. --------- Signed-off-by: MrEconomical <47700125+MrEconomical@users.noreply.github.com>
This commit is contained in:
parent
bfea49f36b
commit
3ba50bf0c9
1 changed files with 3 additions and 2 deletions
|
@ -246,12 +246,13 @@ pub fn cpu_info() -> Option<Vec<CpuInfo>> {
|
|||
let reader = std::io::BufReader::new(fp);
|
||||
|
||||
let mut count = 0;
|
||||
for (i, line) in reader.lines().enumerate() {
|
||||
// Skip the first line which tracks total CPU time across all cores
|
||||
for (i, line) in reader.lines().skip(1).enumerate() {
|
||||
let line = line.ok()?;
|
||||
if !line.starts_with("cpu") {
|
||||
break;
|
||||
}
|
||||
count = i;
|
||||
count = i + 1;
|
||||
let mut fields = line.split_whitespace();
|
||||
fields.next()?;
|
||||
let user = fields.next()?.parse::<u64>().ok()?;
|
||||
|
|
Loading…
Reference in a new issue