Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use ProcessBuilder for power command #7

Merged
merged 2 commits into from
Dec 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -237,10 +237,7 @@ public void start(long frequency) throws Exception {
if (!isStarted()) {
// it takes some time for the external process in addition to the sampling time so adjust the sampling frequency to account for this so that at most one measure occurs during the sampling time window
final var freq = Long.toString(frequency - 50);
// powermetrics = new ProcessBuilder().command("sudo", "powermetrics", "--samplers cpu_power,tasks", "--show-process-samp-norm", "--show-process-gpu", "-i " + freq).start(); // for some reason this doesn't work
powermetrics = Runtime.getRuntime()
.exec("sudo powermetrics --samplers cpu_power,tasks --show-process-samp-norm --show-process-gpu -i " + freq);

powermetrics = new ProcessBuilder().command("sudo", "powermetrics", "--samplers", "cpu_power,tasks", "--show-process-samp-norm", "--show-process-gpu", "-i", freq).start();
}
}

Expand All @@ -251,8 +248,6 @@ public boolean isStarted() {

@Override
public Map<RegisteredPID, double[]> update(Long tick) {
System.out.println("tick = " + tick);
System.out.println("trackedPIDs = " + trackedPIDs);
return extractPowerMeasure(powermetrics.getInputStream());
}

Expand Down