mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
add improvements from oshi maintainer recommendations
This commit is contained in:
parent
22107a853a
commit
273177eb8f
@ -17,16 +17,14 @@
|
|||||||
|
|
||||||
package io.nosqlbench.engine.api.activityimpl;
|
package io.nosqlbench.engine.api.activityimpl;
|
||||||
|
|
||||||
import oshi.SystemInfo;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import oshi.SystemInfo;
|
||||||
import oshi.hardware.CentralProcessor;
|
import oshi.hardware.CentralProcessor;
|
||||||
import oshi.hardware.HardwareAbstractionLayer;
|
import oshi.hardware.HardwareAbstractionLayer;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.util.DoubleSummaryStatistics;
|
||||||
import java.nio.file.Files;
|
import java.util.Optional;
|
||||||
import java.nio.file.Path;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
public class CpuInfo {
|
public class CpuInfo {
|
||||||
private final static Logger logger = LoggerFactory.getLogger(CpuInfo.class);
|
private final static Logger logger = LoggerFactory.getLogger(CpuInfo.class);
|
||||||
@ -61,8 +59,8 @@ public class CpuInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getMhz() {
|
public String getMhz() {
|
||||||
// or use processor.getCurrentFreq, and average, or min?
|
double vendorFreq = processor.getProcessorIdentifier().getVendorFreq();
|
||||||
return Long.toString(processor.getMaxFreq()/ (1024*1024));
|
return String.valueOf((long) (vendorFreq/1E6));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
@ -84,8 +82,8 @@ public class CpuInfo {
|
|||||||
public double getCurrentSpeed(int cpu) {
|
public double getCurrentSpeed(int cpu) {
|
||||||
double curFreq = getCurFreq(cpu);
|
double curFreq = getCurFreq(cpu);
|
||||||
double maxFreq = getMaxFreq(cpu);
|
double maxFreq = getMaxFreq(cpu);
|
||||||
if (Double.isNaN(curFreq) || Double.isNaN(maxFreq)) {
|
if (curFreq < 0 || maxFreq < 0) {
|
||||||
return Double.NaN;
|
return -1;
|
||||||
}
|
}
|
||||||
return curFreq / maxFreq;
|
return curFreq / maxFreq;
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,6 @@
|
|||||||
<netty.version>4.1.47.Final</netty.version>
|
<netty.version>4.1.47.Final</netty.version>
|
||||||
<!-- <netty.version>4.1.31.Final</netty.version>-->
|
<!-- <netty.version>4.1.31.Final</netty.version>-->
|
||||||
<number.to.words.version>1.0.0</number.to.words.version>
|
<number.to.words.version>1.0.0</number.to.words.version>
|
||||||
<oshi.version>4.5.0</oshi.version>
|
|
||||||
<slf4j.version>1.7.29</slf4j.version>
|
<slf4j.version>1.7.29</slf4j.version>
|
||||||
<snakeyaml.version>1.23</snakeyaml.version>
|
<snakeyaml.version>1.23</snakeyaml.version>
|
||||||
<snappy.version>1.1.2.6</snappy.version>
|
<snappy.version>1.1.2.6</snappy.version>
|
||||||
@ -269,7 +268,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.oshi</groupId>
|
<groupId>com.github.oshi</groupId>
|
||||||
<artifactId>oshi-core</artifactId>
|
<artifactId>oshi-core</artifactId>
|
||||||
<version>${oshi.version}</version>
|
<version>5.2.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
|
Loading…
Reference in New Issue
Block a user