Skip to content

Commit

Permalink
refactor: clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
metacosm committed Jan 26, 2024
1 parent ea44d87 commit 35d8977
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,15 @@ public abstract class MacOSPowermetricsSensor implements PowerSensor {
public static final String CPU = "CPU";
public static final String GPU = "GPU";
public static final String ANE = "ANE";
@SuppressWarnings("unused")
public static final String DRAM = "DRAM";
@SuppressWarnings("unused")
public static final String DCS = "DCS";
public static final String PACKAGE = "Package";
public static final String CPU_SHARE = "cpuShare";

private final Measures measures = new MapMeasures();
protected CPU cpu;

protected MacOSPowermetricsSensor() {
}

MacOSPowermetricsSensor(InputStream inputStream) {
initMetadata(inputStream);
}
private CPU cpu;

void initMetadata(InputStream inputStream) {
try (BufferedReader input = new BufferedReader(new InputStreamReader(inputStream))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public boolean isStarted() {
}

@Override
public void start(long samplingFrequencyInMillis) throws Exception {
public void start(long samplingFrequencyInMillis) {
if (!started) {
started = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import io.quarkus.test.Mock;

@Mock
@SuppressWarnings("unused")
public class MockPowerMeasurer extends PowerMeasurer {

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import io.quarkus.test.Mock;

@Mock
@SuppressWarnings("unused")
public class MockPowerSensor extends ResourceMacOSPowermetricsSensor {
public MockPowerSensor() {
super("sonoma-m1max.txt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import static org.junit.jupiter.api.Assertions.assertEquals;

import java.io.*;

import org.junit.jupiter.api.Test;

import io.github.metacosm.power.SensorMetadata;
Expand All @@ -13,7 +11,7 @@
class MacOSPowermetricsSensorTest {

@Test
void checkMetadata() throws IOException {
void checkMetadata() {
var metadata = loadMetadata("sonoma-m1max.txt");
assertEquals(4, metadata.componentCardinality());
checkComponent(metadata, "CPU", 0);
Expand All @@ -37,7 +35,7 @@ void checkMetadata() throws IOException {
checkComponent(metadata, "cpuShare", 1);
}

private static SensorMetadata loadMetadata(String fileName) throws IOException {
private static SensorMetadata loadMetadata(String fileName) {
return new ResourceMacOSPowermetricsSensor(fileName).metadata();
}

Expand Down Expand Up @@ -90,7 +88,6 @@ private static void checkPowerMeasure(String testFileName, float total, String t

private static double getComponent(Measures measure, RegisteredPID pid1, SensorMetadata.ComponentMetadata metadata) {
final var index = metadata.index();
final boolean isInWatt = metadata.unit().equals("W");
return measure.getOrDefault(pid1).components()[index];
}
}

0 comments on commit 35d8977

Please sign in to comment.