blob: 312e7d5c0c1c69361f31b08dfbc6b3d63c3e272b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
/*
* Copyright 2019 Oath Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
*/
package ai.vespa.metricsproxy.service;
class CpuJiffies {
private int cpuId;
private long jiffies;
CpuJiffies(String line) {
parseLine(line);
}
private void parseLine(String line) {
String elems[];
String cpuId;
long jiffies;
elems = line.split("\\s+");
cpuId = elems[0].substring(3);
if (cpuId.length() == 0) {
this.cpuId = -1;
} else {
this.cpuId = Integer.parseInt(cpuId);
}
jiffies = 0;
for (int i = 1; i < elems.length; i++) {
jiffies += Long.parseLong(elems[i].replaceAll("[\\n\\r]+", ""));
}
this.jiffies = jiffies;
}
public int getCpuId() {
return cpuId;
}
public long getTotalJiffies() {
return jiffies;
}
}
|