From 9d9f1ca4c465b5eab413eb2c1b245baf0c6883a8 Mon Sep 17 00:00:00 2001 From: Arjan Lamers Date: Mon, 15 Jan 2024 21:42:24 +0100 Subject: [PATCH 1/4] added support for intel mac power measurements fixed potential missed messages when buffer wasn't fully read added test cases --- .../joularjx/cpu/PowermetricsMacOS.java | 47 ++- .../joularjx/cpu/PowermetricsMacOSTest.java | 97 +++++ src/test/resources/powermetrics-intel.txt | 341 ++++++++++++++++++ src/test/resources/powermetrics-m1-m2.txt | 26 ++ 4 files changed, 494 insertions(+), 17 deletions(-) create mode 100644 src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java create mode 100644 src/test/resources/powermetrics-intel.txt create mode 100644 src/test/resources/powermetrics-m1-m2.txt diff --git a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java index 492b675..4e034b1 100644 --- a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java +++ b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java @@ -4,6 +4,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.io.InputStream; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; @@ -13,9 +14,11 @@ */ public class PowermetricsMacOS implements Cpu { private static final Logger logger = JoularJXLogging.getLogger(); - private static final String POWER_INDICATOR = " Power: "; - private static final int POWER_INDICATOR_LENGTH = POWER_INDICATOR.length(); + private static final String POWER_INDICATOR_M_CHIP = " Power: "; + private static final String POWER_INDICATOR_INTEL_CHIP = "Intel energy model derived package power (CPUs+GT+SA): "; private Process process; + private BufferedReader reader; + private boolean initialized; @Override @@ -27,6 +30,7 @@ public void initialize() { try { // todo: detect when sudo fails as this currently won't throw an exception process = Runtime.getRuntime().exec("sudo powermetrics --samplers cpu_power -i 1000"); + reader = new BufferedReader(new InputStreamReader(process.getInputStream())); initialized = true; } catch (Exception exception) { logger.log(Level.SEVERE, "Can't start powermetrics. Exiting..."); @@ -45,11 +49,9 @@ public double getCurrentPower(double cpuLoad) { int headerLinesToSkip = 10; int powerInMilliwatts = 0; try { - // Should not be closed since it closes the process, so no try-with-resource - BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream())); String line; - boolean processingPower = false; - while ((line = input.readLine()) != null) { + BufferedReader reader = getReader(); + while (reader.ready() && (line = reader.readLine()) != null) { if (headerLinesToSkip != 0) { headerLinesToSkip--; continue; @@ -61,19 +63,17 @@ public double getCurrentPower(double cpuLoad) { } // looking for line fitting the: " Power: xxx mW" pattern and add all of the associated values together - final var powerIndicatorIndex = line.indexOf(POWER_INDICATOR); - - // we need an exit condition to avoid looping forever (since there are always new lines, the process being periodical) - // if we started processing power lines and we don't find any anymore, we've reached the end of this "page" so exit the loop - if(processingPower && powerIndicatorIndex < 0) { - break; - } + // or, for Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern + final var powerIndicatorIndexM = line.indexOf(POWER_INDICATOR_M_CHIP); + final var powerIndicatorIndexIntel = line.indexOf(POWER_INDICATOR_INTEL_CHIP); // lines with `-` as the second char are disregarded as of the form: "E-Cluster Power: 6 mW" which fits the pattern but shouldn't be considered // also ignore Combined Power if available since it is the sum of the other components - if (powerIndicatorIndex >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { - powerInMilliwatts += extractPowerInMilliwatts(line, powerIndicatorIndex); - processingPower = true; // record we're in the power lines section of the powermetrics output + if (powerIndicatorIndexM >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { + powerInMilliwatts += extractPowerInMilliwatts(line, powerIndicatorIndexM + POWER_INDICATOR_M_CHIP.length()); + } + if (powerIndicatorIndexIntel >= 0) { + powerInMilliwatts += extractPowerInMilliwatts(line, powerIndicatorIndexIntel + POWER_INDICATOR_INTEL_CHIP.length()); } } return (double) powerInMilliwatts / 1000; @@ -84,9 +84,22 @@ public double getCurrentPower(double cpuLoad) { return 0.0; } + /** + * Override point for testing. + */ + protected BufferedReader getReader() { + return reader; + } + private static int extractPowerInMilliwatts(String line, int powerIndex) { try { - return Integer.parseInt(line.substring(powerIndex + POWER_INDICATOR_LENGTH, line.indexOf('m') - 1)); + if (line.trim().endsWith("mW")) { + return Integer.parseInt(line.substring(powerIndex, line.indexOf('m') - 1)); + } else if (line.trim().endsWith("W")) { + return (int) (1000.0 * Double.parseDouble(line.substring(powerIndex, line.indexOf('W')))); + } else { + logger.log(Level.SEVERE, "Power line does not end with mW or W, ignoring line: " + line); + } } catch (Exception e) { logger.log(Level.SEVERE, "Cannot parse power value from line '" + line + "'", e); } diff --git a/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java new file mode 100644 index 0000000..4b27332 --- /dev/null +++ b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java @@ -0,0 +1,97 @@ +package org.noureddine.joularjx.cpu; + +import org.junit.jupiter.api.Test; + +import java.io.*; +import java.net.URISyntaxException; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class PowermetricsMacOSTest { + + @Test + void parseM1M2PowerLines() { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-m1-m2.txt"))); + } + }; + + // the ??-Cluster lines are to be ignored, hence do not count the 100mW + assertEquals(/*0.100d +*/ 0d + 0.688d+0.742d + 0.026d + 2.151d, cpu.getCurrentPower(0), 0.0001d); + } + + /** + * Test if the reader returns whenever there are results. + * @throws IOException + */ + @Test + void testIntermittentResults() throws IOException, URISyntaxException, InterruptedException { + // hookup a writer to a reader + PipedInputStream intermittentInputStream = new PipedInputStream(); + PipedOutputStream outputStream = new PipedOutputStream(intermittentInputStream); + BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(outputStream)); + BufferedReader reader = new BufferedReader(new InputStreamReader(intermittentInputStream)); + + // create the content blocks including headers + final String contents1 = "\n".repeat(10) + "CPU Power: 742 mW\n".repeat(2); + final String contents2 = "\n".repeat(10) + "CPU Power: 1.2W\n".repeat(2); + + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return reader; + } + }; + + // nothing written yet, so expect 0 + assertEquals(0d, cpu.getCurrentPower(0), 0.0001d); + + Thread writerBlock1 = createWriter(writer, contents1); + writerBlock1.start(); + writerBlock1.join(); + assertEquals(2*0.742d, cpu.getCurrentPower(0), 0.0001d); + + Thread writerBlock2 = createWriter(writer, contents2); + writerBlock2.start(); + writerBlock2.join(); + assertEquals(2*1.2d, cpu.getCurrentPower(0), 0.0001d); + } + + /** + * Create a thread that writes the contents to the writer, simulating the actual process. + * @param writer the writer to write to + * @param contents the contents to write + * @return a thread + */ + private static Thread createWriter(BufferedWriter writer, String contents) { + Thread writerBlock1 = new Thread() { + @Override + public void run() { + try { + writer.write(contents); + writer.flush(); + } catch(Exception e) { + throw new RuntimeException(e); + } + } + }; + return writerBlock1; + } + + @Test + void parseIntelPowerLines() { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-intel.txt"))); + } + }; + + assertEquals(4.87d + 3.43d + 3.38d + 4.21d + 3.21d , cpu.getCurrentPower(0), 0.0001d); + } + +} diff --git a/src/test/resources/powermetrics-intel.txt b/src/test/resources/powermetrics-intel.txt new file mode 100644 index 0000000..1f6da6c --- /dev/null +++ b/src/test/resources/powermetrics-intel.txt @@ -0,0 +1,341 @@ +Machine model: MacBookPro15,1 +SMC version: Unknown +EFI version: 2020.1.0 +OS version: 23C71 +Boot arguments: +Boot time: Thu Dec 21 08:07:54 2023 + + + +*** Sampled system activity (Mon Jan 15 20:18:34 2024 +0100) (1002.80ms elapsed) *** + + +**** Processor usage **** + +Intel energy model derived package power (CPUs+GT+SA): 4.87W + +LLC flushed residency: 45.7% + +System Average frequency as fraction of nominal: 81.81% (2127.00 Mhz) +Package 0 C-state residency: 49.49% (C2: 32.66% C3: 16.83% C6: 0.00% C7: 0.00% C8: 0.00% C9: 0.00% C10: 0.00% ) + +Performance Limited Due to: +CPU LIMIT TURBO_ATTENUATION +CPU/GPU Overlap: 2.97% +Cores Active: 42.61% +GPU Active: 4.41% +Avg Num of Cores Active: 0.76 + +Core 0 C-state residency: 71.73% (C3: 0.65% C6: 0.00% C7: 71.08% ) + +CPU 0 duty cycles/s: active/idle [< 16 us: 303.15/112.68] [< 32 us: 148.58/18.95] [< 64 us: 195.45/203.43] [< 128 us: 397.89/221.38] [< 256 us: 208.42/126.65] [< 512 us: 106.70/199.44] [< 1024 us: 38.89/225.37] [< 2048 us: 11.97/256.28] [< 4096 us: 1.99/48.86] [< 8192 us: 2.99/4.99] [< 16384 us: 0.00/0.00] [< 32768 us: 1.00/0.00] +CPU Average frequency as fraction of nominal: 76.58% (1991.00 Mhz) + +CPU 1 duty cycles/s: active/idle [< 16 us: 1362.18/58.84] [< 32 us: 7.98/45.87] [< 64 us: 5.98/141.60] [< 128 us: 2.99/211.41] [< 256 us: 1.00/198.44] [< 512 us: 0.00/162.54] [< 1024 us: 0.00/172.52] [< 2048 us: 0.00/282.21] [< 4096 us: 0.00/85.76] [< 8192 us: 0.00/19.94] [< 16384 us: 0.00/1.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 72.27% (1878.91 Mhz) + +Core 1 C-state residency: 76.85% (C3: 0.93% C6: 0.00% C7: 75.91% ) + +CPU 2 duty cycles/s: active/idle [< 16 us: 459.71/174.51] [< 32 us: 184.48/27.92] [< 64 us: 178.50/185.48] [< 128 us: 243.32/197.45] [< 256 us: 115.68/146.59] [< 512 us: 81.77/105.70] [< 1024 us: 18.95/153.57] [< 2048 us: 5.98/198.44] [< 4096 us: 2.99/79.78] [< 8192 us: 1.00/22.94] [< 16384 us: 0.00/1.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 85.92% (2233.86 Mhz) + +CPU 3 duty cycles/s: active/idle [< 16 us: 1121.86/137.61] [< 32 us: 5.98/132.63] [< 64 us: 9.97/158.56] [< 128 us: 1.99/139.61] [< 256 us: 1.00/137.61] [< 512 us: 0.00/85.76] [< 1024 us: 0.00/78.78] [< 2048 us: 0.00/106.70] [< 4096 us: 0.00/93.74] [< 8192 us: 0.00/59.83] [< 16384 us: 0.00/8.97] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 73.11% (1900.84 Mhz) + +Core 2 C-state residency: 82.58% (C3: 0.91% C6: 0.00% C7: 81.66% ) + +CPU 4 duty cycles/s: active/idle [< 16 us: 465.70/237.33] [< 32 us: 247.31/8.97] [< 64 us: 166.53/161.55] [< 128 us: 166.53/188.47] [< 256 us: 97.73/130.63] [< 512 us: 68.81/103.71] [< 1024 us: 17.95/114.68] [< 2048 us: 5.98/162.54] [< 4096 us: 1.99/93.74] [< 8192 us: 1.00/37.89] [< 16384 us: 1.00/1.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 79.10% (2056.54 Mhz) + +CPU 5 duty cycles/s: active/idle [< 16 us: 1365.17/298.16] [< 32 us: 6.98/162.54] [< 64 us: 9.97/150.58] [< 128 us: 1.99/139.61] [< 256 us: 0.00/141.60] [< 512 us: 0.00/101.71] [< 1024 us: 0.00/93.74] [< 2048 us: 0.00/147.59] [< 4096 us: 0.00/83.77] [< 8192 us: 0.00/57.84] [< 16384 us: 0.00/6.98] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 73.36% (1907.48 Mhz) + +Core 3 C-state residency: 85.18% (C3: 1.06% C6: 0.00% C7: 84.12% ) + +CPU 6 duty cycles/s: active/idle [< 16 us: 544.47/193.46] [< 32 us: 163.54/32.91] [< 64 us: 106.70/125.65] [< 128 us: 115.68/160.55] [< 256 us: 69.80/106.70] [< 512 us: 51.85/94.73] [< 1024 us: 17.95/109.69] [< 2048 us: 4.99/111.69] [< 4096 us: 0.00/77.78] [< 8192 us: 0.00/60.83] [< 16384 us: 0.00/1.00] [< 32768 us: 1.00/0.00] +CPU Average frequency as fraction of nominal: 91.17% (2370.52 Mhz) + +CPU 7 duty cycles/s: active/idle [< 16 us: 186.48/15.96] [< 32 us: 6.98/5.98] [< 64 us: 7.98/16.95] [< 128 us: 1.99/17.95] [< 256 us: 0.00/16.95] [< 512 us: 0.00/12.96] [< 1024 us: 0.00/13.96] [< 2048 us: 0.00/14.96] [< 4096 us: 0.00/16.95] [< 8192 us: 0.00/22.94] [< 16384 us: 0.00/28.92] [< 32768 us: 0.00/17.95] +CPU Average frequency as fraction of nominal: 81.61% (2121.81 Mhz) + +Core 4 C-state residency: 92.64% (C3: 0.85% C6: 0.00% C7: 91.79% ) + +CPU 8 duty cycles/s: active/idle [< 16 us: 326.09/36.90] [< 32 us: 42.88/2.99] [< 64 us: 56.84/65.82] [< 128 us: 48.86/82.77] [< 256 us: 35.90/56.84] [< 512 us: 19.94/39.89] [< 1024 us: 7.98/42.88] [< 2048 us: 1.00/69.80] [< 4096 us: 0.00/57.84] [< 8192 us: 0.00/64.82] [< 16384 us: 1.99/18.95] [< 32768 us: 0.00/1.99] +CPU Average frequency as fraction of nominal: 82.25% (2138.61 Mhz) + +CPU 9 duty cycles/s: active/idle [< 16 us: 337.06/18.95] [< 32 us: 6.98/24.93] [< 64 us: 4.99/45.87] [< 128 us: 1.00/50.86] [< 256 us: 2.99/41.88] [< 512 us: 0.00/22.94] [< 1024 us: 0.00/11.97] [< 2048 us: 0.00/30.91] [< 4096 us: 0.00/24.93] [< 8192 us: 0.00/32.91] [< 16384 us: 0.00/34.90] [< 32768 us: 0.00/10.97] +CPU Average frequency as fraction of nominal: 75.20% (1955.32 Mhz) + +Core 5 C-state residency: 96.24% (C3: 0.00% C6: 0.00% C7: 96.24% ) + +CPU 10 duty cycles/s: active/idle [< 16 us: 280.21/26.92] [< 32 us: 24.93/1.99] [< 64 us: 46.87/54.85] [< 128 us: 39.89/56.84] [< 256 us: 21.94/46.87] [< 512 us: 12.96/31.91] [< 1024 us: 2.99/26.92] [< 2048 us: 0.00/57.84] [< 4096 us: 1.00/38.89] [< 8192 us: 0.00/53.85] [< 16384 us: 0.00/27.92] [< 32768 us: 0.00/5.98] +CPU Average frequency as fraction of nominal: 75.53% (1963.85 Mhz) + +CPU 11 duty cycles/s: active/idle [< 16 us: 41.88/2.99] [< 32 us: 1.00/1.00] [< 64 us: 1.00/2.99] [< 128 us: 3.99/1.00] [< 256 us: 1.00/3.99] [< 512 us: 0.00/1.99] [< 1024 us: 0.00/2.99] [< 2048 us: 0.00/1.00] [< 4096 us: 0.00/3.99] [< 8192 us: 0.00/3.99] [< 16384 us: 0.00/4.99] [< 32768 us: 0.00/5.98] +CPU Average frequency as fraction of nominal: 70.88% (1843.00 Mhz) + + +*** Sampled system activity (Mon Jan 15 20:18:35 2024 +0100) (1004.07ms elapsed) *** + + +**** Processor usage **** + +Intel energy model derived package power (CPUs+GT+SA): 3.43W + +LLC flushed residency: 56.2% + +System Average frequency as fraction of nominal: 64.01% (1664.23 Mhz) +Package 0 C-state residency: 59.61% (C2: 39.10% C3: 20.50% C6: 0.00% C7: 0.00% C8: 0.00% C9: 0.00% C10: 0.00% ) +CPU/GPU Overlap: 2.24% +Cores Active: 32.61% +GPU Active: 2.97% +Avg Num of Cores Active: 0.60 + +Core 0 C-state residency: 74.06% (C3: 0.04% C6: 0.00% C7: 74.02% ) + +CPU 0 duty cycles/s: active/idle [< 16 us: 212.14/225.08] [< 32 us: 237.04/32.87] [< 64 us: 160.35/141.42] [< 128 us: 437.22/156.36] [< 256 us: 171.30/112.54] [< 512 us: 97.60/177.28] [< 1024 us: 51.79/185.25] [< 2048 us: 5.98/285.84] [< 4096 us: 3.98/48.80] [< 8192 us: 1.00/12.95] [< 16384 us: 0.00/0.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 63.49% (1650.68 Mhz) + +CPU 1 duty cycles/s: active/idle [< 16 us: 1408.27/169.31] [< 32 us: 3.98/121.51] [< 64 us: 1.99/140.43] [< 128 us: 1.00/161.34] [< 256 us: 0.00/147.40] [< 512 us: 0.00/135.45] [< 1024 us: 0.00/145.41] [< 2048 us: 0.00/273.89] [< 4096 us: 0.00/92.62] [< 8192 us: 0.00/26.89] [< 16384 us: 0.00/1.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 62.62% (1628.21 Mhz) + +Core 1 C-state residency: 82.57% (C3: 0.19% C6: 0.00% C7: 82.37% ) + +CPU 2 duty cycles/s: active/idle [< 16 us: 377.46/143.42] [< 32 us: 125.49/28.88] [< 64 us: 183.25/141.42] [< 128 us: 289.82/187.24] [< 256 us: 111.55/113.54] [< 512 us: 59.76/94.61] [< 1024 us: 25.89/127.48] [< 2048 us: 3.98/236.04] [< 4096 us: 1.99/75.69] [< 8192 us: 1.00/27.89] [< 16384 us: 0.00/3.98] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 65.61% (1705.78 Mhz) + +CPU 3 duty cycles/s: active/idle [< 16 us: 903.32/72.70] [< 32 us: 2.99/93.62] [< 64 us: 7.97/122.50] [< 128 us: 2.99/104.57] [< 256 us: 0.00/115.53] [< 512 us: 0.00/76.69] [< 1024 us: 0.00/53.78] [< 2048 us: 0.00/99.59] [< 4096 us: 0.00/110.55] [< 8192 us: 0.00/57.76] [< 16384 us: 0.00/9.96] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 65.17% (1694.39 Mhz) + +Core 2 C-state residency: 86.64% (C3: 1.43% C6: 0.00% C7: 85.21% ) + +CPU 4 duty cycles/s: active/idle [< 16 us: 420.29/128.48] [< 32 us: 120.51/40.83] [< 64 us: 155.37/126.49] [< 128 us: 160.35/182.26] [< 256 us: 79.68/93.62] [< 512 us: 54.78/74.70] [< 1024 us: 14.94/93.62] [< 2048 us: 1.99/107.56] [< 4096 us: 1.00/112.54] [< 8192 us: 1.00/40.83] [< 16384 us: 0.00/7.97] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 65.33% (1698.65 Mhz) + +CPU 5 duty cycles/s: active/idle [< 16 us: 965.07/112.54] [< 32 us: 1.00/112.54] [< 64 us: 4.98/121.51] [< 128 us: 1.99/118.52] [< 256 us: 0.00/115.53] [< 512 us: 0.00/61.75] [< 1024 us: 0.00/71.71] [< 2048 us: 0.00/96.61] [< 4096 us: 0.00/92.62] [< 8192 us: 0.00/51.79] [< 16384 us: 0.00/17.93] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 64.51% (1677.15 Mhz) + +Core 3 C-state residency: 89.38% (C3: 0.35% C6: 0.00% C7: 89.03% ) + +CPU 6 duty cycles/s: active/idle [< 16 us: 395.39/104.57] [< 32 us: 78.68/39.84] [< 64 us: 86.65/90.63] [< 128 us: 130.47/112.54] [< 256 us: 60.75/82.66] [< 512 us: 49.80/53.78] [< 1024 us: 15.94/67.72] [< 2048 us: 2.99/107.56] [< 4096 us: 0.00/106.57] [< 8192 us: 0.00/44.82] [< 16384 us: 0.00/9.96] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 62.37% (1621.70 Mhz) + +CPU 7 duty cycles/s: active/idle [< 16 us: 157.36/1.99] [< 32 us: 3.98/2.99] [< 64 us: 2.99/7.97] [< 128 us: 1.00/10.96] [< 256 us: 1.99/17.93] [< 512 us: 0.00/6.97] [< 1024 us: 0.00/9.96] [< 2048 us: 0.00/9.96] [< 4096 us: 0.00/24.90] [< 8192 us: 0.00/30.87] [< 16384 us: 0.00/23.90] [< 32768 us: 0.00/17.93] +CPU Average frequency as fraction of nominal: 71.57% (1860.85 Mhz) + +Core 4 C-state residency: 95.40% (C3: 0.42% C6: 0.00% C7: 94.97% ) + +CPU 8 duty cycles/s: active/idle [< 16 us: 241.02/25.89] [< 32 us: 20.91/1.99] [< 64 us: 69.72/39.84] [< 128 us: 43.82/53.78] [< 256 us: 28.88/57.76] [< 512 us: 17.93/34.86] [< 1024 us: 5.98/29.88] [< 2048 us: 1.00/46.81] [< 4096 us: 0.00/54.78] [< 8192 us: 0.00/49.80] [< 16384 us: 0.00/28.88] [< 32768 us: 0.00/4.98] +CPU Average frequency as fraction of nominal: 63.09% (1640.22 Mhz) + +CPU 9 duty cycles/s: active/idle [< 16 us: 272.89/14.94] [< 32 us: 3.98/18.92] [< 64 us: 5.98/38.84] [< 128 us: 1.00/28.88] [< 256 us: 1.99/25.89] [< 512 us: 0.00/9.96] [< 1024 us: 0.00/18.92] [< 2048 us: 0.00/24.90] [< 4096 us: 0.00/29.88] [< 8192 us: 0.00/35.85] [< 16384 us: 0.00/22.91] [< 32768 us: 0.00/13.94] +CPU Average frequency as fraction of nominal: 66.46% (1727.95 Mhz) + +Core 5 C-state residency: 95.05% (C3: 0.00% C6: 0.00% C7: 95.05% ) + +CPU 10 duty cycles/s: active/idle [< 16 us: 171.30/27.89] [< 32 us: 21.91/3.98] [< 64 us: 40.83/39.84] [< 128 us: 34.86/31.87] [< 256 us: 49.80/33.86] [< 512 us: 28.88/27.89] [< 1024 us: 6.97/25.89] [< 2048 us: 2.99/33.86] [< 4096 us: 0.00/47.81] [< 8192 us: 0.00/47.81] [< 16384 us: 0.00/31.87] [< 32768 us: 0.00/3.98] +CPU Average frequency as fraction of nominal: 61.69% (1604.04 Mhz) + +CPU 11 duty cycles/s: active/idle [< 16 us: 22.91/0.00] [< 32 us: 0.00/1.00] [< 64 us: 3.98/1.00] [< 128 us: 1.00/0.00] [< 256 us: 0.00/1.99] [< 512 us: 0.00/1.00] [< 1024 us: 0.00/1.99] [< 2048 us: 0.00/0.00] [< 4096 us: 0.00/0.00] [< 8192 us: 0.00/3.98] [< 16384 us: 0.00/3.98] [< 32768 us: 0.00/2.99] +CPU Average frequency as fraction of nominal: 63.59% (1653.39 Mhz) + + +*** Sampled system activity (Mon Jan 15 20:18:36 2024 +0100) (1003.46ms elapsed) *** + + +**** Processor usage **** + +Intel energy model derived package power (CPUs+GT+SA): 3.38W + +LLC flushed residency: 58% + +System Average frequency as fraction of nominal: 64.68% (1681.60 Mhz) +Package 0 C-state residency: 60.69% (C2: 39.26% C3: 21.43% C6: 0.00% C7: 0.00% C8: 0.00% C9: 0.00% C10: 0.00% ) +CPU/GPU Overlap: 0.00% +Cores Active: 32.43% +GPU Active: 0.00% +Avg Num of Cores Active: 0.57 + +Core 0 C-state residency: 75.05% (C3: 0.00% C6: 0.00% C7: 75.05% ) + +CPU 0 duty cycles/s: active/idle [< 16 us: 211.27/130.55] [< 32 us: 154.47/14.95] [< 64 us: 117.59/122.58] [< 128 us: 393.64/166.42] [< 256 us: 171.41/84.71] [< 512 us: 89.69/153.47] [< 1024 us: 45.84/182.37] [< 2048 us: 8.97/275.05] [< 4096 us: 1.99/46.84] [< 8192 us: 0.00/18.93] [< 16384 us: 0.00/0.00] [< 32768 us: 1.00/0.00] +CPU Average frequency as fraction of nominal: 66.25% (1722.55 Mhz) + +CPU 1 duty cycles/s: active/idle [< 16 us: 1246.69/77.73] [< 32 us: 1.99/80.72] [< 64 us: 5.98/135.53] [< 128 us: 4.98/193.33] [< 256 us: 1.00/134.53] [< 512 us: 1.00/133.54] [< 1024 us: 0.00/113.61] [< 2048 us: 0.00/273.06] [< 4096 us: 0.00/88.69] [< 8192 us: 0.00/30.89] [< 16384 us: 0.00/0.00] [< 32768 us: 0.00/1.00] +CPU Average frequency as fraction of nominal: 60.98% (1585.42 Mhz) + +Core 1 C-state residency: 83.77% (C3: 0.18% C6: 0.00% C7: 83.59% ) + +CPU 2 duty cycles/s: active/idle [< 16 us: 335.84/138.52] [< 32 us: 126.56/16.94] [< 64 us: 165.43/122.58] [< 128 us: 280.03/171.41] [< 256 us: 98.66/82.71] [< 512 us: 67.77/93.68] [< 1024 us: 26.91/129.55] [< 2048 us: 4.98/233.19] [< 4096 us: 0.00/89.69] [< 8192 us: 0.00/25.91] [< 16384 us: 0.00/1.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 60.46% (1571.88 Mhz) + +CPU 3 duty cycles/s: active/idle [< 16 us: 861.02/92.68] [< 32 us: 1.99/73.75] [< 64 us: 1.00/96.67] [< 128 us: 1.99/119.59] [< 256 us: 1.00/106.63] [< 512 us: 0.00/68.76] [< 1024 us: 0.00/48.83] [< 2048 us: 0.00/84.71] [< 4096 us: 0.00/94.67] [< 8192 us: 0.00/73.75] [< 16384 us: 0.00/5.98] [< 32768 us: 0.00/1.00] +CPU Average frequency as fraction of nominal: 63.34% (1646.86 Mhz) + +Core 2 C-state residency: 87.54% (C3: 0.01% C6: 0.00% C7: 87.53% ) + +CPU 4 duty cycles/s: active/idle [< 16 us: 317.90/180.38] [< 32 us: 183.37/22.92] [< 64 us: 142.51/79.72] [< 128 us: 150.48/119.59] [< 256 us: 72.75/83.71] [< 512 us: 44.84/56.80] [< 1024 us: 20.93/83.71] [< 2048 us: 4.98/153.47] [< 4096 us: 0.00/104.64] [< 8192 us: 0.00/49.83] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 62.81% (1633.07 Mhz) + +CPU 5 duty cycles/s: active/idle [< 16 us: 1079.27/276.05] [< 32 us: 1.00/172.40] [< 64 us: 4.98/83.71] [< 128 us: 1.99/85.70] [< 256 us: 0.00/81.72] [< 512 us: 0.00/68.76] [< 1024 us: 1.00/60.79] [< 2048 us: 0.00/106.63] [< 4096 us: 0.00/70.76] [< 8192 us: 0.00/63.78] [< 16384 us: 0.00/17.94] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 63.19% (1642.94 Mhz) + +Core 3 C-state residency: 90.69% (C3: 0.00% C6: 0.00% C7: 90.68% ) + +CPU 6 duty cycles/s: active/idle [< 16 us: 396.63/151.48] [< 32 us: 100.65/46.84] [< 64 us: 100.65/94.67] [< 128 us: 82.71/98.66] [< 256 us: 63.78/57.80] [< 512 us: 39.86/50.82] [< 1024 us: 12.96/53.81] [< 2048 us: 3.99/74.74] [< 4096 us: 0.00/93.68] [< 8192 us: 0.00/66.77] [< 16384 us: 0.00/11.96] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 62.81% (1633.18 Mhz) + +CPU 7 duty cycles/s: active/idle [< 16 us: 125.57/5.98] [< 32 us: 4.98/3.99] [< 64 us: 0.00/3.99] [< 128 us: 1.00/4.98] [< 256 us: 1.00/12.96] [< 512 us: 0.00/8.97] [< 1024 us: 0.00/7.97] [< 2048 us: 0.00/9.97] [< 4096 us: 0.00/10.96] [< 8192 us: 0.00/16.94] [< 16384 us: 0.00/30.89] [< 32768 us: 0.00/9.97] +CPU Average frequency as fraction of nominal: 58.66% (1525.22 Mhz) + +Core 4 C-state residency: 94.19% (C3: 0.00% C6: 0.00% C7: 94.19% ) + +CPU 8 duty cycles/s: active/idle [< 16 us: 156.46/19.93] [< 32 us: 13.95/1.99] [< 64 us: 43.85/36.87] [< 128 us: 45.84/47.83] [< 256 us: 27.90/15.94] [< 512 us: 18.93/17.94] [< 1024 us: 5.98/16.94] [< 2048 us: 3.99/39.86] [< 4096 us: 0.00/37.87] [< 8192 us: 0.00/38.87] [< 16384 us: 1.00/39.86] [< 32768 us: 0.00/4.98] +CPU Average frequency as fraction of nominal: 77.32% (2010.36 Mhz) + +CPU 9 duty cycles/s: active/idle [< 16 us: 223.23/11.96] [< 32 us: 1.00/8.97] [< 64 us: 5.98/27.90] [< 128 us: 0.00/32.89] [< 256 us: 1.00/11.96] [< 512 us: 0.00/21.92] [< 1024 us: 0.00/7.97] [< 2048 us: 0.00/13.95] [< 4096 us: 0.00/15.94] [< 8192 us: 0.00/30.89] [< 16384 us: 0.00/31.89] [< 32768 us: 0.00/12.96] +CPU Average frequency as fraction of nominal: 59.17% (1538.50 Mhz) + +Core 5 C-state residency: 96.84% (C3: 0.00% C6: 0.00% C7: 96.84% ) + +CPU 10 duty cycles/s: active/idle [< 16 us: 109.62/8.97] [< 32 us: 6.98/1.99] [< 64 us: 21.92/22.92] [< 128 us: 34.88/21.92] [< 256 us: 27.90/12.96] [< 512 us: 11.96/14.95] [< 1024 us: 10.96/12.96] [< 2048 us: 1.00/23.92] [< 4096 us: 0.00/31.89] [< 8192 us: 0.00/34.88] [< 16384 us: 0.00/24.91] [< 32768 us: 0.00/11.96] +CPU Average frequency as fraction of nominal: 60.28% (1567.23 Mhz) + +CPU 11 duty cycles/s: active/idle [< 16 us: 13.95/1.00] [< 32 us: 3.99/0.00] [< 64 us: 1.99/1.00] [< 128 us: 1.99/1.00] [< 256 us: 1.00/0.00] [< 512 us: 1.00/0.00] [< 1024 us: 0.00/1.99] [< 2048 us: 0.00/1.00] [< 4096 us: 0.00/0.00] [< 8192 us: 0.00/1.00] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/2.99] +CPU Average frequency as fraction of nominal: 60.71% (1578.43 Mhz) + + +*** Sampled system activity (Mon Jan 15 20:18:37 2024 +0100) (1003.06ms elapsed) *** + + +**** Processor usage **** + +Intel energy model derived package power (CPUs+GT+SA): 4.21W + +LLC flushed residency: 54.2% + +System Average frequency as fraction of nominal: 74.44% (1935.33 Mhz) +Package 0 C-state residency: 57.44% (C2: 38.09% C3: 19.36% C6: 0.00% C7: 0.00% C8: 0.00% C9: 0.00% C10: 0.00% ) + +Performance Limited Due to: +CPU LIMIT ICCMAX/PL4/OTHER +CPU LIMIT MAX_TURBO_LIMIT +CPU LIMIT TURBO_ATTENUATION +GPU LIMIT ICCMAX/PL4/OTHER +CPU/GPU Overlap: 0.00% +Cores Active: 35.48% +GPU Active: 0.00% +Avg Num of Cores Active: 0.61 + +Core 0 C-state residency: 76.26% (C3: 1.25% C6: 0.00% C7: 75.01% ) + +CPU 0 duty cycles/s: active/idle [< 16 us: 288.12/114.65] [< 32 us: 150.54/26.92] [< 64 us: 143.56/188.42] [< 128 us: 399.78/184.44] [< 256 us: 202.38/91.72] [< 512 us: 98.70/176.46] [< 1024 us: 44.86/222.32] [< 2048 us: 8.97/262.20] [< 4096 us: 1.00/58.82] [< 8192 us: 0.00/11.96] [< 16384 us: 0.00/0.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 65.32% (1698.38 Mhz) + +CPU 1 duty cycles/s: active/idle [< 16 us: 1225.25/32.90] [< 32 us: 12.96/53.84] [< 64 us: 7.98/143.56] [< 128 us: 3.99/197.40] [< 256 us: 2.99/155.52] [< 512 us: 0.00/143.56] [< 1024 us: 0.00/153.53] [< 2048 us: 0.00/240.26] [< 4096 us: 0.00/107.67] [< 8192 us: 0.00/21.93] [< 16384 us: 0.00/1.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 69.34% (1802.88 Mhz) + +Core 1 C-state residency: 83.71% (C3: 0.68% C6: 0.00% C7: 83.03% ) + +CPU 2 duty cycles/s: active/idle [< 16 us: 383.82/144.56] [< 32 us: 101.69/11.96] [< 64 us: 197.40/150.54] [< 128 us: 290.11/194.40] [< 256 us: 101.69/108.67] [< 512 us: 72.78/68.79] [< 1024 us: 19.94/147.55] [< 2048 us: 1.99/226.31] [< 4096 us: 1.99/93.71] [< 8192 us: 0.00/21.93] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 67.89% (1765.21 Mhz) + +CPU 3 duty cycles/s: active/idle [< 16 us: 825.47/89.73] [< 32 us: 6.98/75.77] [< 64 us: 10.97/98.70] [< 128 us: 1.99/108.67] [< 256 us: 1.99/82.75] [< 512 us: 0.00/59.82] [< 1024 us: 0.00/61.81] [< 2048 us: 0.00/94.71] [< 4096 us: 0.00/111.66] [< 8192 us: 0.00/47.85] [< 16384 us: 0.00/15.95] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 70.95% (1844.76 Mhz) + +Core 2 C-state residency: 81.87% (C3: 0.42% C6: 0.00% C7: 81.44% ) + +CPU 4 duty cycles/s: active/idle [< 16 us: 324.01/152.53] [< 32 us: 159.51/23.93] [< 64 us: 136.58/117.64] [< 128 us: 145.55/125.62] [< 256 us: 65.80/86.73] [< 512 us: 57.82/57.82] [< 1024 us: 23.93/75.77] [< 2048 us: 4.98/135.58] [< 4096 us: 1.99/100.69] [< 8192 us: 0.00/42.87] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 92.94% (2416.47 Mhz) + +CPU 5 duty cycles/s: active/idle [< 16 us: 950.09/134.59] [< 32 us: 4.98/144.56] [< 64 us: 7.98/140.57] [< 128 us: 7.98/104.68] [< 256 us: 1.00/66.80] [< 512 us: 0.00/63.80] [< 1024 us: 0.00/55.83] [< 2048 us: 0.00/106.67] [< 4096 us: 0.00/76.76] [< 8192 us: 0.00/61.81] [< 16384 us: 0.00/13.96] [< 32768 us: 0.00/1.99] +CPU Average frequency as fraction of nominal: 70.47% (1832.32 Mhz) + +Core 3 C-state residency: 90.00% (C3: 0.02% C6: 0.00% C7: 89.98% ) + +CPU 6 duty cycles/s: active/idle [< 16 us: 410.74/125.62] [< 32 us: 88.73/49.85] [< 64 us: 85.74/86.73] [< 128 us: 83.74/108.67] [< 256 us: 57.82/65.80] [< 512 us: 31.90/34.89] [< 1024 us: 10.97/52.84] [< 2048 us: 3.99/83.74] [< 4096 us: 0.00/91.72] [< 8192 us: 0.00/61.81] [< 16384 us: 1.00/12.96] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 79.26% (2060.74 Mhz) + +CPU 7 duty cycles/s: active/idle [< 16 us: 142.56/14.95] [< 32 us: 4.98/7.98] [< 64 us: 8.97/5.98] [< 128 us: 3.99/10.97] [< 256 us: 1.00/15.95] [< 512 us: 0.00/10.97] [< 1024 us: 0.00/6.98] [< 2048 us: 0.00/9.97] [< 4096 us: 0.00/9.97] [< 8192 us: 0.00/18.94] [< 16384 us: 0.00/32.90] [< 32768 us: 0.00/10.97] +CPU Average frequency as fraction of nominal: 68.37% (1777.64 Mhz) + +Core 4 C-state residency: 95.33% (C3: 0.00% C6: 0.00% C7: 95.33% ) + +CPU 8 duty cycles/s: active/idle [< 16 us: 213.35/30.91] [< 32 us: 18.94/4.98] [< 64 us: 42.87/39.88] [< 128 us: 49.85/48.85] [< 256 us: 23.93/22.93] [< 512 us: 26.92/25.92] [< 1024 us: 7.98/13.96] [< 2048 us: 1.99/49.85] [< 4096 us: 0.00/58.82] [< 8192 us: 0.00/59.82] [< 16384 us: 0.00/26.92] [< 32768 us: 0.00/1.99] +CPU Average frequency as fraction of nominal: 64.77% (1683.97 Mhz) + +CPU 9 duty cycles/s: active/idle [< 16 us: 262.20/26.92] [< 32 us: 2.99/27.91] [< 64 us: 5.98/26.92] [< 128 us: 2.99/33.90] [< 256 us: 1.00/23.93] [< 512 us: 0.00/12.96] [< 1024 us: 0.00/6.98] [< 2048 us: 0.00/11.96] [< 4096 us: 0.00/26.92] [< 8192 us: 0.00/29.91] [< 16384 us: 0.00/31.90] [< 32768 us: 0.00/11.96] +CPU Average frequency as fraction of nominal: 70.50% (1833.04 Mhz) + +Core 5 C-state residency: 96.41% (C3: 0.23% C6: 0.00% C7: 96.18% ) + +CPU 10 duty cycles/s: active/idle [< 16 us: 151.54/32.90] [< 32 us: 12.96/2.99] [< 64 us: 48.85/46.86] [< 128 us: 46.86/29.91] [< 256 us: 18.94/14.95] [< 512 us: 16.95/10.97] [< 1024 us: 10.97/15.95] [< 2048 us: 1.00/29.91] [< 4096 us: 0.00/35.89] [< 8192 us: 0.00/45.86] [< 16384 us: 0.00/28.91] [< 32768 us: 0.00/11.96] +CPU Average frequency as fraction of nominal: 63.56% (1652.48 Mhz) + +CPU 11 duty cycles/s: active/idle [< 16 us: 30.91/1.99] [< 32 us: 2.99/0.00] [< 64 us: 7.98/7.98] [< 128 us: 2.99/4.98] [< 256 us: 2.99/1.99] [< 512 us: 0.00/1.99] [< 1024 us: 0.00/1.99] [< 2048 us: 0.00/3.99] [< 4096 us: 0.00/1.99] [< 8192 us: 0.00/1.00] [< 16384 us: 0.00/3.99] [< 32768 us: 0.00/5.98] +CPU Average frequency as fraction of nominal: 75.71% (1968.52 Mhz) + + +*** Sampled system activity (Mon Jan 15 20:18:38 2024 +0100) (1003.03ms elapsed) *** + + +**** Processor usage **** + +Intel energy model derived package power (CPUs+GT+SA): 3.21W + +LLC flushed residency: 57.5% + +System Average frequency as fraction of nominal: 59.77% (1553.99 Mhz) +Package 0 C-state residency: 60.79% (C2: 39.87% C3: 20.91% C6: 0.00% C7: 0.00% C8: 0.00% C9: 0.00% C10: 0.00% ) +CPU/GPU Overlap: 0.00% +Cores Active: 32.26% +GPU Active: 0.00% +Avg Num of Cores Active: 0.58 + +Core 0 C-state residency: 75.63% (C3: 0.00% C6: 0.00% C7: 75.63% ) + +CPU 0 duty cycles/s: active/idle [< 16 us: 207.37/182.45] [< 32 us: 249.25/53.84] [< 64 us: 126.62/143.57] [< 128 us: 368.88/160.51] [< 256 us: 181.45/87.73] [< 512 us: 115.65/188.43] [< 1024 us: 56.83/162.51] [< 2048 us: 6.98/260.21] [< 4096 us: 1.00/53.84] [< 8192 us: 0.00/20.94] [< 16384 us: 0.00/0.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 58.69% (1525.84 Mhz) + +CPU 1 duty cycles/s: active/idle [< 16 us: 1390.79/163.50] [< 32 us: 6.98/152.54] [< 64 us: 4.98/137.58] [< 128 us: 6.98/172.48] [< 256 us: 0.00/138.58] [< 512 us: 0.00/136.59] [< 1024 us: 0.00/126.62] [< 2048 us: 0.00/256.22] [< 4096 us: 0.00/92.72] [< 8192 us: 0.00/31.90] [< 16384 us: 0.00/1.00] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 60.58% (1575.02 Mhz) + +Core 1 C-state residency: 83.62% (C3: 0.20% C6: 0.00% C7: 83.42% ) + +CPU 2 duty cycles/s: active/idle [< 16 us: 310.06/179.46] [< 32 us: 181.45/7.98] [< 64 us: 162.51/109.67] [< 128 us: 285.14/150.54] [< 256 us: 96.71/107.67] [< 512 us: 76.77/102.69] [< 1024 us: 26.92/133.60] [< 2048 us: 2.99/242.27] [< 4096 us: 0.00/80.76] [< 8192 us: 0.00/25.92] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 58.51% (1521.35 Mhz) + +CPU 3 duty cycles/s: active/idle [< 16 us: 913.23/127.61] [< 32 us: 3.99/122.63] [< 64 us: 6.98/105.68] [< 128 us: 3.99/94.71] [< 256 us: 0.00/94.71] [< 512 us: 0.00/59.82] [< 1024 us: 0.00/54.83] [< 2048 us: 0.00/96.71] [< 4096 us: 0.00/95.71] [< 8192 us: 0.00/63.81] [< 16384 us: 0.00/11.96] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 63.11% (1640.76 Mhz) + +Core 2 C-state residency: 86.05% (C3: 0.56% C6: 0.00% C7: 85.48% ) + +CPU 4 duty cycles/s: active/idle [< 16 us: 372.87/131.60] [< 32 us: 92.72/47.86] [< 64 us: 166.50/115.65] [< 128 us: 115.65/126.62] [< 256 us: 77.76/82.75] [< 512 us: 56.83/60.82] [< 1024 us: 21.93/65.80] [< 2048 us: 2.99/126.62] [< 4096 us: 1.00/98.70] [< 8192 us: 0.00/46.86] [< 16384 us: 1.00/4.98] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 64.48% (1676.61 Mhz) + +CPU 5 duty cycles/s: active/idle [< 16 us: 860.39/108.67] [< 32 us: 4.98/99.70] [< 64 us: 4.98/104.68] [< 128 us: 4.98/91.72] [< 256 us: 1.99/93.72] [< 512 us: 0.00/61.81] [< 1024 us: 0.00/52.84] [< 2048 us: 0.00/103.69] [< 4096 us: 0.00/83.75] [< 8192 us: 0.00/57.82] [< 16384 us: 0.00/17.95] [< 32768 us: 0.00/1.00] +CPU Average frequency as fraction of nominal: 59.42% (1544.96 Mhz) + +Core 3 C-state residency: 90.93% (C3: 0.27% C6: 0.00% C7: 90.67% ) + +CPU 6 duty cycles/s: active/idle [< 16 us: 308.07/74.77] [< 32 us: 47.86/21.93] [< 64 us: 94.71/71.78] [< 128 us: 105.68/89.73] [< 256 us: 53.84/44.86] [< 512 us: 49.85/50.85] [< 1024 us: 11.96/50.85] [< 2048 us: 1.99/110.66] [< 4096 us: 0.00/88.73] [< 8192 us: 0.00/60.82] [< 16384 us: 0.00/9.97] [< 32768 us: 0.00/0.00] +CPU Average frequency as fraction of nominal: 57.97% (1507.26 Mhz) + +CPU 7 duty cycles/s: active/idle [< 16 us: 153.54/13.96] [< 32 us: 1.00/7.98] [< 64 us: 7.98/9.97] [< 128 us: 1.00/12.96] [< 256 us: 1.99/12.96] [< 512 us: 0.00/12.96] [< 1024 us: 0.00/3.99] [< 2048 us: 0.00/11.96] [< 4096 us: 0.00/16.95] [< 8192 us: 0.00/13.96] [< 16384 us: 0.00/24.92] [< 32768 us: 0.00/18.94] +CPU Average frequency as fraction of nominal: 60.39% (1570.13 Mhz) + +Core 4 C-state residency: 94.78% (C3: 0.00% C6: 0.00% C7: 94.78% ) + +CPU 8 duty cycles/s: active/idle [< 16 us: 159.52/18.94] [< 32 us: 20.94/3.99] [< 64 us: 29.91/40.88] [< 128 us: 50.85/28.91] [< 256 us: 37.89/19.94] [< 512 us: 23.93/18.94] [< 1024 us: 6.98/20.94] [< 2048 us: 1.00/47.86] [< 4096 us: 1.00/38.88] [< 8192 us: 1.00/57.82] [< 16384 us: 0.00/32.90] [< 32768 us: 0.00/2.99] +CPU Average frequency as fraction of nominal: 59.35% (1542.99 Mhz) + +CPU 9 duty cycles/s: active/idle [< 16 us: 237.28/12.96] [< 32 us: 3.99/11.96] [< 64 us: 4.98/33.90] [< 128 us: 1.99/23.93] [< 256 us: 2.99/24.92] [< 512 us: 0.00/11.96] [< 1024 us: 1.00/10.97] [< 2048 us: 0.00/23.93] [< 4096 us: 0.00/23.93] [< 8192 us: 0.00/26.92] [< 16384 us: 0.00/31.90] [< 32768 us: 0.00/13.96] +CPU Average frequency as fraction of nominal: 61.44% (1597.36 Mhz) + +Core 5 C-state residency: 96.54% (C3: 0.00% C6: 0.00% C7: 96.54% ) + +CPU 10 duty cycles/s: active/idle [< 16 us: 118.64/21.93] [< 32 us: 14.95/3.99] [< 64 us: 31.90/28.91] [< 128 us: 42.87/26.92] [< 256 us: 15.95/7.98] [< 512 us: 15.95/10.97] [< 1024 us: 4.98/13.96] [< 2048 us: 1.99/34.89] [< 4096 us: 0.00/22.93] [< 8192 us: 1.00/31.90] [< 16384 us: 0.00/27.92] [< 32768 us: 0.00/15.95] +CPU Average frequency as fraction of nominal: 58.78% (1528.32 Mhz) + +CPU 11 duty cycles/s: active/idle [< 16 us: 21.93/1.00] [< 32 us: 1.00/0.00] [< 64 us: 1.99/0.00] [< 128 us: 1.99/1.99] [< 256 us: 1.00/1.00] [< 512 us: 0.00/0.00] [< 1024 us: 0.00/1.00] [< 2048 us: 0.00/2.99] [< 4096 us: 0.00/0.00] [< 8192 us: 0.00/1.00] [< 16384 us: 0.00/2.99] [< 32768 us: 0.00/2.99] +CPU Average frequency as fraction of nominal: 68.15% (1771.79 Mhz) diff --git a/src/test/resources/powermetrics-m1-m2.txt b/src/test/resources/powermetrics-m1-m2.txt new file mode 100644 index 0000000..562036d --- /dev/null +++ b/src/test/resources/powermetrics-m1-m2.txt @@ -0,0 +1,26 @@ +P1-Cluster Power: 100 mW +P1-Cluster HW active frequency: 679 MHz +P1-Cluster HW active residency: 2.27% (600 MHz: 95% 828 MHz: 0% 1056 MHz: .52% 1296 MHz: .55% 1524 MHz: .82% 1752 MHz: .19% 1980 MHz: .68% 2208 MHz: .34% 2448 MHz: .20% 2676 MHz: .22% 2904 MHz: 0% 3036 MHz: .45% 3132 MHz: .03% 3168 MHz: 0% 3228 MHz: 1.1%) +P1-Cluster idle residency: 97.73% +P1-Cluster instructions retired: 5.13456e+08 +P1-Cluster instructions per clock: 1.78784 +CPU 6 frequency: 2367 MHz +CPU 6 idle residency: 97.76% +CPU 6 active residency: 2.24% (600 MHz: .03% 828 MHz: 0% 1056 MHz: .09% 1296 MHz: .19% 1524 MHz: .39% 1752 MHz: .13% 1980 MHz: .20% 2208 MHz: .03% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .98%) +CPU 7 frequency: 2233 MHz +CPU 7 idle residency: 98.51% +CPU 7 active residency: 1.49% (600 MHz: .00% 828 MHz: 0% 1056 MHz: .02% 1296 MHz: .18% 1524 MHz: .39% 1752 MHz: .02% 1980 MHz: .18% 2208 MHz: 0% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .49%) +CPU 8 frequency: 2247 MHz +CPU 8 idle residency: 98.58% +CPU 8 active residency: 1.42% (600 MHz: .00% 828 MHz: 0% 1056 MHz: .00% 1296 MHz: .16% 1524 MHz: .39% 1752 MHz: .00% 1980 MHz: .20% 2208 MHz: 0% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .47%) +CPU 9 frequency: 2247 MHz +CPU 9 idle residency: 98.59% +CPU 9 active residency: 1.41% (600 MHz: .00% 828 MHz: 0% 1056 MHz: 0% 1296 MHz: .17% 1524 MHz: .39% 1752 MHz: 0% 1980 MHz: .20% 2208 MHz: 0% 2448 MHz: .19% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .47%) + +System instructions retired: 1.25248e+10 +System instructions per clock: 1.35631 +ANE Power: 0 mW +DRAM Power: 688 mW +CPU Power: 742 mW +GPU Power: 26 mW +Package Power: 2151 mW From 7cc085027db63e7c091f782d9b933327a3dd6c47 Mon Sep 17 00:00:00 2001 From: Arjan Lamers Date: Mon, 15 Jan 2024 21:51:59 +0100 Subject: [PATCH 2/4] some cleanup and mentioning origin of data --- .../java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java | 1 - .../org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java index 4e034b1..ba8aa1e 100644 --- a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java +++ b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java @@ -4,7 +4,6 @@ import java.io.BufferedReader; import java.io.IOException; -import java.io.InputStream; import java.io.InputStreamReader; import java.util.logging.Level; import java.util.logging.Logger; diff --git a/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java index 4b27332..b303e02 100644 --- a/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java +++ b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java @@ -4,8 +4,6 @@ import java.io.*; import java.net.URISyntaxException; -import java.nio.file.Files; -import java.nio.file.Paths; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,6 +14,7 @@ void parseM1M2PowerLines() { PowermetricsMacOS cpu = new PowermetricsMacOS() { @Override protected BufferedReader getReader() { + // using data from https://abhimanbhau.github.io/mac/m1-mac-power-usage-monitor/ return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-m1-m2.txt"))); } }; From fc403622c741f5a36e6bb79c4f8de0328e46f03a Mon Sep 17 00:00:00 2001 From: Arjan Lamers Date: Tue, 23 Jan 2024 11:35:54 +0100 Subject: [PATCH 3/4] replaced m1/m2 test resources from https://github.com/metacosm/power-server/tree/main moved intel vs m chip parsing to separate functions for performance added readHeader to detect intel vs m chip --- .../joularjx/cpu/PowermetricsMacOS.java | 64 +++++-- .../joularjx/cpu/PowermetricsMacOSTest.java | 81 ++++++-- src/test/resources/powermetrics-m1-m2.txt | 26 --- .../resources/powermetrics-monterey-m2.txt | 68 +++++++ ...ntel.txt => powermetrics-sonoma-intel.txt} | 0 .../resources/powermetrics-sonoma-m1max.txt | 178 ++++++++++++++++++ 6 files changed, 358 insertions(+), 59 deletions(-) delete mode 100644 src/test/resources/powermetrics-m1-m2.txt create mode 100644 src/test/resources/powermetrics-monterey-m2.txt rename src/test/resources/{powermetrics-intel.txt => powermetrics-sonoma-intel.txt} (100%) create mode 100644 src/test/resources/powermetrics-sonoma-m1max.txt diff --git a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java index ba8aa1e..3c75d2c 100644 --- a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java +++ b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java @@ -19,6 +19,7 @@ public class PowermetricsMacOS implements Cpu { private BufferedReader reader; private boolean initialized; + boolean intelCpu = false; @Override public void initialize() { @@ -31,6 +32,7 @@ public void initialize() { process = Runtime.getRuntime().exec("sudo powermetrics --samplers cpu_power -i 1000"); reader = new BufferedReader(new InputStreamReader(process.getInputStream())); initialized = true; + readHeader(); } catch (Exception exception) { logger.log(Level.SEVERE, "Can't start powermetrics. Exiting..."); logger.throwing(getClass().getName(), "initialize", exception); @@ -38,6 +40,16 @@ public void initialize() { } } + void readHeader() throws IOException { + BufferedReader reader = getReader(); + for (int i=0; i<6; i++) { + String line = reader.readLine(); + if (line.startsWith("EFI version")) { + intelCpu = true; + } + } + } + @Override public double getInitialPower() { return 0; @@ -45,17 +57,46 @@ public double getInitialPower() { @Override public double getCurrentPower(double cpuLoad) { - int headerLinesToSkip = 10; - int powerInMilliwatts = 0; + if (intelCpu) { + return getCurrentPowerIntel(); + } else { + return getCurrentPowerM(); + } + } + + private double getCurrentPowerIntel() { + double powerInWatts = 0; try { String line; BufferedReader reader = getReader(); while (reader.ready() && (line = reader.readLine()) != null) { - if (headerLinesToSkip != 0) { - headerLinesToSkip--; + + // skip empty / header lines + if (line.isEmpty() || line.startsWith("*")) { continue; } + // ofor Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern + final var i = line.indexOf(POWER_INDICATOR_INTEL_CHIP); + if (i >= 0) { + powerInWatts += Double.parseDouble(line.substring(i + POWER_INDICATOR_INTEL_CHIP.length(), line.indexOf('W'))); + } + } + return powerInWatts; + } catch (IOException e) { + logger.throwing(getClass().getName(), "getCurrentPower", e); + } + + return 0.0; + } + + public double getCurrentPowerM() { + int powerInMilliwatts = 0; + try { + String line; + BufferedReader reader = getReader(); + while (reader.ready() && (line = reader.readLine()) != null) { + // skip empty / header lines if (line.isEmpty() || line.startsWith("*")) { continue; @@ -63,17 +104,10 @@ public double getCurrentPower(double cpuLoad) { // looking for line fitting the: " Power: xxx mW" pattern and add all of the associated values together // or, for Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern - final var powerIndicatorIndexM = line.indexOf(POWER_INDICATOR_M_CHIP); - final var powerIndicatorIndexIntel = line.indexOf(POWER_INDICATOR_INTEL_CHIP); - - // lines with `-` as the second char are disregarded as of the form: "E-Cluster Power: 6 mW" which fits the pattern but shouldn't be considered - // also ignore Combined Power if available since it is the sum of the other components - if (powerIndicatorIndexM >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { - powerInMilliwatts += extractPowerInMilliwatts(line, powerIndicatorIndexM + POWER_INDICATOR_M_CHIP.length()); - } - if (powerIndicatorIndexIntel >= 0) { - powerInMilliwatts += extractPowerInMilliwatts(line, powerIndicatorIndexIntel + POWER_INDICATOR_INTEL_CHIP.length()); - } + final var i = line.indexOf(POWER_INDICATOR_M_CHIP); + if (i >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { + powerInMilliwatts += Integer.parseInt(line.substring(i + POWER_INDICATOR_M_CHIP.length(), line.indexOf('m') - 1)); + } } return (double) powerInMilliwatts / 1000; } catch (IOException e) { diff --git a/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java index b303e02..6e9edca 100644 --- a/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java +++ b/src/test/java/org/noureddine/joularjx/cpu/PowermetricsMacOSTest.java @@ -5,22 +5,78 @@ import java.io.*; import java.net.URISyntaxException; -import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.*; public class PowermetricsMacOSTest { @Test - void parseM1M2PowerLines() { + void parseSonomaM1MaxPowerLines() { PowermetricsMacOS cpu = new PowermetricsMacOS() { @Override protected BufferedReader getReader() { - // using data from https://abhimanbhau.github.io/mac/m1-mac-power-usage-monitor/ - return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-m1-m2.txt"))); + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-sonoma-m1max.txt"))); } }; + cpu.intelCpu = false; - // the ??-Cluster lines are to be ignored, hence do not count the 100mW - assertEquals(/*0.100d +*/ 0d + 0.688d+0.742d + 0.026d + 2.151d, cpu.getCurrentPower(0), 0.0001d); + + // the ??-Cluster and Combined lines are to be ignored, hence do not count the 359mW + assertEquals(0.211d + 0.147d + 0d /* +0.359d */, cpu.getCurrentPower(0), 0.0001d); + } + + @Test + void parseMontereyM2PowerLines() { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-monterey-m2.txt"))); + } + }; + cpu.intelCpu = false; + + // the ??-Cluster and Combined lines are to be ignored, hence do not count the 6mW + assertEquals(/*0.006d*/ + 0d + 0.019d + 0.036d + 0.010d + 0d + 0.025d , cpu.getCurrentPower(0), 0.0001d); + } + + @Test + void parseSonomaIntelPowerLines() { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-sonoma-intel.txt"))); + } + }; + + cpu.intelCpu = true; + + assertEquals(4.87d + 3.43d + 3.38d + 4.21d + 3.21d , cpu.getCurrentPower(0), 0.0001d); + } + + + @Test + void parseHeaderIntel() throws IOException { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-sonoma-intel.txt"))); + } + }; + + cpu.readHeader(); + assertTrue(cpu.intelCpu); + } + + @Test + void parseHeaderM1() throws IOException { + PowermetricsMacOS cpu = new PowermetricsMacOS() { + @Override + protected BufferedReader getReader() { + return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-monterey-m2.txt"))); + } + }; + + cpu.readHeader(); + assertFalse(cpu.intelCpu); } /** @@ -37,7 +93,7 @@ void testIntermittentResults() throws IOException, URISyntaxException, Interrupt // create the content blocks including headers final String contents1 = "\n".repeat(10) + "CPU Power: 742 mW\n".repeat(2); - final String contents2 = "\n".repeat(10) + "CPU Power: 1.2W\n".repeat(2); + final String contents2 = "\n".repeat(10) + "CPU Power: 1200 mW\n".repeat(2); PowermetricsMacOS cpu = new PowermetricsMacOS() { @Override @@ -81,16 +137,5 @@ public void run() { return writerBlock1; } - @Test - void parseIntelPowerLines() { - PowermetricsMacOS cpu = new PowermetricsMacOS() { - @Override - protected BufferedReader getReader() { - return new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("/powermetrics-intel.txt"))); - } - }; - - assertEquals(4.87d + 3.43d + 3.38d + 4.21d + 3.21d , cpu.getCurrentPower(0), 0.0001d); - } } diff --git a/src/test/resources/powermetrics-m1-m2.txt b/src/test/resources/powermetrics-m1-m2.txt deleted file mode 100644 index 562036d..0000000 --- a/src/test/resources/powermetrics-m1-m2.txt +++ /dev/null @@ -1,26 +0,0 @@ -P1-Cluster Power: 100 mW -P1-Cluster HW active frequency: 679 MHz -P1-Cluster HW active residency: 2.27% (600 MHz: 95% 828 MHz: 0% 1056 MHz: .52% 1296 MHz: .55% 1524 MHz: .82% 1752 MHz: .19% 1980 MHz: .68% 2208 MHz: .34% 2448 MHz: .20% 2676 MHz: .22% 2904 MHz: 0% 3036 MHz: .45% 3132 MHz: .03% 3168 MHz: 0% 3228 MHz: 1.1%) -P1-Cluster idle residency: 97.73% -P1-Cluster instructions retired: 5.13456e+08 -P1-Cluster instructions per clock: 1.78784 -CPU 6 frequency: 2367 MHz -CPU 6 idle residency: 97.76% -CPU 6 active residency: 2.24% (600 MHz: .03% 828 MHz: 0% 1056 MHz: .09% 1296 MHz: .19% 1524 MHz: .39% 1752 MHz: .13% 1980 MHz: .20% 2208 MHz: .03% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .98%) -CPU 7 frequency: 2233 MHz -CPU 7 idle residency: 98.51% -CPU 7 active residency: 1.49% (600 MHz: .00% 828 MHz: 0% 1056 MHz: .02% 1296 MHz: .18% 1524 MHz: .39% 1752 MHz: .02% 1980 MHz: .18% 2208 MHz: 0% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .49%) -CPU 8 frequency: 2247 MHz -CPU 8 idle residency: 98.58% -CPU 8 active residency: 1.42% (600 MHz: .00% 828 MHz: 0% 1056 MHz: .00% 1296 MHz: .16% 1524 MHz: .39% 1752 MHz: .00% 1980 MHz: .20% 2208 MHz: 0% 2448 MHz: .20% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .47%) -CPU 9 frequency: 2247 MHz -CPU 9 idle residency: 98.59% -CPU 9 active residency: 1.41% (600 MHz: .00% 828 MHz: 0% 1056 MHz: 0% 1296 MHz: .17% 1524 MHz: .39% 1752 MHz: 0% 1980 MHz: .20% 2208 MHz: 0% 2448 MHz: .19% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .47%) - -System instructions retired: 1.25248e+10 -System instructions per clock: 1.35631 -ANE Power: 0 mW -DRAM Power: 688 mW -CPU Power: 742 mW -GPU Power: 26 mW -Package Power: 2151 mW diff --git a/src/test/resources/powermetrics-monterey-m2.txt b/src/test/resources/powermetrics-monterey-m2.txt new file mode 100644 index 0000000..1e08b2d --- /dev/null +++ b/src/test/resources/powermetrics-monterey-m2.txt @@ -0,0 +1,68 @@ +Machine model: Mac14,2 +OS version: 21G72 +Boot arguments: +Boot time: Mon Oct 2 10:37:21 2023 + + + +*** Sampled system activity (Mon Oct 23 16:51:12 2023 +0200) (1012.07ms elapsed) *** + +*** Running tasks *** + +Name ID CPU ms/s samp ms/s User% Deadlines (<2 ms, 2-5 ms) Wakeups (Intr, Pkg idle) GPU ms/s +WindowServer 391 281.98 283.25 82.97 1.97 0.00 428.87 8.85 0.00 +mdworker_shared 29420 183.26 112.83 65.49 0.00 0.00 0.00 0.00 0.00 +powermetrics 29419 23.78 23.88 6.05 0.00 0.00 0.98 0.00 0.00 +ALL_TASKS -2 1222.65 1222.65 65.70 1161.97 15.81 2875.29 132.40 0.00 + +*** Sampled system activity (Tue Nov 28 11:28:55 2023 +0100) (1002.80ms elapsed) *** + + +**** Processor usage **** + +E-Cluster Power: 6 mW +E-Cluster HW active frequency: 919 MHz +E-Cluster HW active residency: 5.37% (600 MHz: 0% 912 MHz: 100% 1284 MHz: 0% 1752 MHz: 0% 2004 MHz: 0% 2256 MHz: 0% 2424 MHz: .44%) +E-Cluster idle residency: 94.63% +E-Cluster instructions retired: 5.66564e+07 +E-Cluster instructions per clock: 0.996462 +CPU 0 frequency: 920 MHz +CPU 0 idle residency: 97.09% +CPU 0 active residency: 2.91% (600 MHz: 0% 912 MHz: 2.9% 1284 MHz: 0% 1752 MHz: 0% 2004 MHz: 0% 2256 MHz: 0% 2424 MHz: .02%) +CPU 1 frequency: 922 MHz +CPU 1 idle residency: 98.03% +CPU 1 active residency: 1.97% (600 MHz: 0% 912 MHz: 2.0% 1284 MHz: 0% 1752 MHz: 0% 2004 MHz: 0% 2256 MHz: 0% 2424 MHz: .01%) +CPU 2 frequency: 943 MHz +CPU 2 idle residency: 98.82% +CPU 2 active residency: 1.18% (600 MHz: 0% 912 MHz: 1.2% 1284 MHz: 0% 1752 MHz: 0% 2004 MHz: 0% 2256 MHz: 0% 2424 MHz: .02%) +CPU 3 frequency: 913 MHz +CPU 3 idle residency: 99.04% +CPU 3 active residency: 0.96% (600 MHz: 0% 912 MHz: .96% 1284 MHz: 0% 1752 MHz: 0% 2004 MHz: 0% 2256 MHz: 0% 2424 MHz: .00%) + +P-Cluster Power: 4 mW +P-Cluster HW active frequency: 667 MHz +P-Cluster HW active residency: 0.00% (660 MHz: 100% 924 MHz: 0% 1188 MHz: 0% 1452 MHz: 0% 1704 MHz: 0% 1968 MHz: 0% 2208 MHz: 0% 2400 MHz: 0% 2568 MHz: 0% 2724 MHz: 0% 2868 MHz: 0% 2988 MHz: 0% 3096 MHz: 0% 3204 MHz: .03% 3324 MHz: .25% 3408 MHz: 0% 3504 MHz: 0%) +P-Cluster idle residency: 100.00% +P-Cluster instructions retired: 6.11748e+07 +P-Cluster instructions per clock: 2.88735 +CPU 4 frequency: 3079 MHz +CPU 4 idle residency: 99.81% +CPU 4 active residency: 0.19% (660 MHz: .03% 924 MHz: 0% 1188 MHz: 0% 1452 MHz: 0% 1704 MHz: 0% 1968 MHz: 0% 2208 MHz: 0% 2400 MHz: 0% 2568 MHz: 0% 2724 MHz: 0% 2868 MHz: 0% 2988 MHz: 0% 3096 MHz: 0% 3204 MHz: 0% 3324 MHz: .04% 3408 MHz: 0% 3504 MHz: .12%) +CPU 5 frequency: 1814 MHz +CPU 5 idle residency: 99.99% +CPU 5 active residency: 0.01% (660 MHz: .00% 924 MHz: 0% 1188 MHz: 0% 1452 MHz: 0% 1704 MHz: 0% 1968 MHz: 0% 2208 MHz: 0% 2400 MHz: 0% 2568 MHz: 0% 2724 MHz: 0% 2868 MHz: 0% 2988 MHz: 0% 3096 MHz: 0% 3204 MHz: 0% 3324 MHz: .00% 3408 MHz: 0% 3504 MHz: 0%) +CPU 6 frequency: 660 MHz +CPU 6 idle residency: 100.00% +CPU 6 active residency: 0.00% (660 MHz: .00% 924 MHz: 0% 1188 MHz: 0% 1452 MHz: 0% 1704 MHz: 0% 1968 MHz: 0% 2208 MHz: 0% 2400 MHz: 0% 2568 MHz: 0% 2724 MHz: 0% 2868 MHz: 0% 2988 MHz: 0% 3096 MHz: 0% 3204 MHz: 0% 3324 MHz: 0% 3408 MHz: 0% 3504 MHz: 0%) +CPU 7 frequency: 660 MHz +CPU 7 idle residency: 100.00% +CPU 7 active residency: 0.00% (660 MHz: .00% 924 MHz: 0% 1188 MHz: 0% 1452 MHz: 0% 1704 MHz: 0% 1968 MHz: 0% 2208 MHz: 0% 2400 MHz: 0% 2568 MHz: 0% 2724 MHz: 0% 2868 MHz: 0% 2988 MHz: 0% 3096 MHz: 0% 3204 MHz: 0% 3324 MHz: 0% 3408 MHz: 0% 3504 MHz: 0%) + +System instructions retired: 1.17831e+08 +System instructions per clock: 1.50979 +ANE Power: 0 mW +DRAM Power: 19 mW +DCS Power: 36 mW +CPU Power: 10 mW +GPU Power: 0 mW +Package Power: 25 mW diff --git a/src/test/resources/powermetrics-intel.txt b/src/test/resources/powermetrics-sonoma-intel.txt similarity index 100% rename from src/test/resources/powermetrics-intel.txt rename to src/test/resources/powermetrics-sonoma-intel.txt diff --git a/src/test/resources/powermetrics-sonoma-m1max.txt b/src/test/resources/powermetrics-sonoma-m1max.txt new file mode 100644 index 0000000..e2e6133 --- /dev/null +++ b/src/test/resources/powermetrics-sonoma-m1max.txt @@ -0,0 +1,178 @@ +Machine model: MacBookPro18,4 +OS version: 22G120 +Boot arguments: +Boot time: Sat Oct 21 19:09:01 2023 + + + +*** Sampled system activity (Mon Oct 23 16:51:12 2023 +0200) (1012.07ms elapsed) *** + +*** Running tasks *** + +Name ID CPU ms/s samp ms/s User% Deadlines (<2 ms, 2-5 ms) Wakeups (Intr, Pkg idle) GPU ms/s +WindowServer 391 281.98 283.25 82.97 1.97 0.00 428.87 8.85 0.00 +mdworker_shared 29420 183.26 112.83 65.49 0.00 0.00 0.00 0.00 0.00 +powermetrics 29419 23.78 23.88 6.05 0.00 0.00 0.98 0.00 0.00 +firefox 678 151.38 152.06 75.55 0.00 0.98 34.43 0.98 0.00 +kernel_task 0 116.12 116.64 0.00 422.96 0.00 805.60 74.76 0.00 +idea 21834 126.37 126.94 64.94 708.22 4.92 898.06 26.56 0.00 +iTerm2 1008 32.62 32.77 76.15 0.00 0.00 22.62 0.00 0.00 +plugin-container 1096 28.85 28.98 84.36 0.00 0.00 6.89 0.00 0.00 +Music 669 41.97 42.16 72.99 0.00 0.00 86.56 0.98 0.00 +coreaudiod 412 35.09 35.25 87.47 0.00 0.00 86.56 1.97 0.00 +plugin-container 1088 41.86 42.05 93.85 9.84 4.92 44.26 0.00 0.00 +plugin-container 1037 24.55 24.67 84.93 4.92 3.93 17.71 0.00 0.00 +plugin-container 1089 13.66 13.72 85.91 0.00 0.00 3.93 0.00 0.00 +cfprefsd 604 6.33 6.36 45.20 0.00 0.00 0.00 0.00 0.00 +DEAD_TASKS -1 12.64 12.64 29.96 0.00 0.00 0.00 0.00 0.00 +launchd 1 7.86 7.90 38.55 0.00 0.00 0.00 0.00 0.00 +jetbrains-toolbox 1015 10.18 10.23 63.26 0.98 0.00 46.23 1.97 0.00 +sentineld 824 10.29 10.34 75.10 0.00 0.00 0.98 0.00 0.00 +cfprefsd 392 4.59 4.61 45.98 0.00 0.00 0.00 0.00 0.00 +splunkd 1501 9.18 9.22 37.18 4.92 0.00 40.33 1.97 0.00 +WindowManager 619 4.12 4.13 88.28 0.00 0.00 0.00 0.00 0.00 +mds_stores 610 5.72 5.75 46.17 0.00 0.00 0.00 0.00 0.00 +mds 350 5.55 5.58 53.73 0.00 0.00 1.97 0.00 0.00 +plugin-container 1085 7.85 7.89 88.19 1.97 0.98 11.80 2.95 0.00 +opendirectoryd 362 3.59 3.61 50.33 0.00 0.00 0.00 0.00 0.00 +Signal Helper (GPU) 26193 2.58 2.59 26.50 0.00 0.00 0.00 0.00 0.00 +notifyd 385 3.49 3.50 59.15 0.00 0.00 0.00 0.00 0.00 +1Password Helper (GPU) 1027 2.08 2.09 28.14 0.00 0.00 0.00 0.00 0.00 +plugin-container 1187 3.58 3.59 88.38 0.00 0.00 13.77 0.98 0.00 +LaunchBar 952 4.79 4.81 69.92 0.00 0.00 52.13 2.95 0.00 +logd 322 3.60 3.62 47.91 0.00 0.00 0.00 0.00 0.00 +OnlySwitch 1017 3.85 3.86 72.79 0.00 0.00 42.30 1.97 0.00 +Ferdi 12523 3.97 3.99 80.01 0.98 0.00 1.97 0.00 0.00 +plugin-container 1186 2.74 2.75 83.76 0.00 0.00 10.82 0.00 0.00 +plugin-container 1119 2.77 2.78 81.36 0.00 0.00 11.80 0.00 0.00 +java 22015 2.95 2.96 59.12 0.00 0.00 24.59 0.00 0.00 +java 21951 3.22 3.24 52.44 0.00 0.00 24.59 0.98 0.00 +plugin-container 23298 2.72 2.73 81.68 0.00 0.00 10.82 0.98 0.00 +java 21923 2.87 2.88 56.29 0.00 0.00 25.57 1.97 0.00 +java 22095 2.85 2.86 57.81 0.00 0.00 24.59 0.98 0.00 +Ferdi Helper (GPU) 12531 1.70 1.71 49.64 0.00 0.00 1.97 0.00 0.00 +jcef Helper (GPU) 21932 1.11 1.12 32.20 0.00 0.00 0.00 0.00 0.00 +diskarbitrationd 353 0.38 0.38 59.74 0.00 0.00 0.00 0.00 0.00 +plugin-container 1114 1.48 1.48 72.19 0.00 0.00 0.98 0.00 0.00 +SentinelAgent 936 1.06 1.07 32.01 0.00 0.00 0.00 0.00 0.00 +fseventsd 327 1.82 1.83 19.75 0.00 0.00 2.95 0.00 0.00 +corebrightnessd 387 2.47 2.48 53.16 0.00 0.00 0.98 0.00 0.00 +com.apple.AmbientDisplayAgent 822 1.73 1.73 56.59 0.00 0.00 0.00 0.00 0.00 +searchpartyd 534 3.02 3.04 85.12 0.00 0.00 0.00 0.00 0.00 +Python 931 2.57 2.59 71.71 0.00 0.00 5.90 0.00 0.00 +Ferdi Helper (Renderer) 12533 1.44 1.44 92.33 0.00 0.00 0.98 0.00 0.00 +sentineld_helper 585 1.60 1.60 43.98 0.00 0.00 0.00 0.00 0.00 +locationd 370 2.31 2.32 71.00 0.00 0.00 0.00 0.00 0.00 +bluetoothd 384 2.60 2.61 61.28 0.00 0.00 0.00 0.00 0.00 +pboard 666 1.44 1.44 47.17 0.00 0.00 0.00 0.00 0.00 +lsd 621 0.84 0.84 53.44 0.00 0.00 0.00 0.00 0.00 +plugin-container 9519 3.07 3.09 91.80 0.00 0.00 2.95 0.00 0.00 +Ferdi Helper 12532 1.37 1.38 77.37 0.00 0.00 3.93 0.00 0.00 +coreservicesd 397 0.76 0.76 54.01 0.00 0.00 0.00 0.00 0.00 +plugin-container 9000 1.11 1.12 75.19 0.00 0.00 3.93 0.00 0.00 +plugin-container 1118 0.84 0.84 80.90 0.00 0.00 3.93 0.00 0.00 +Ferdi Helper (Renderer) 12541 1.09 1.09 93.65 0.00 0.00 0.00 0.00 0.00 +Ferdi Helper (Renderer) 29240 1.49 1.50 90.96 0.00 0.00 1.97 0.00 0.00 +plugin-container 9198 1.00 1.01 77.50 0.00 0.00 3.93 0.00 0.00 +Ferdi Helper (Renderer) 12543 0.78 0.79 91.89 0.00 0.00 0.00 0.00 0.00 +plugin-container 23543 1.34 1.35 92.66 0.00 0.00 1.97 0.00 0.00 +distnoted 603 0.51 0.52 37.12 0.00 0.00 0.00 0.00 0.00 +Finder 700 0.49 0.50 51.78 0.00 0.00 0.00 0.00 0.00 +audioclocksyncd 543 0.84 0.84 57.84 0.00 0.00 0.00 0.00 0.00 +PerfPowerServices 17302 0.96 0.97 83.19 0.00 0.00 0.00 0.00 0.00 +plugin-container 9055 0.63 0.64 87.29 0.00 0.00 1.97 0.00 0.00 +storagekitd 7040 0.34 0.34 53.18 0.00 0.00 0.98 0.00 0.00 +heard 922 0.35 0.35 67.45 0.00 0.00 0.98 0.00 0.00 +lockoutagent 641 0.28 0.29 41.08 0.00 0.00 0.98 0.00 0.00 +nearbyd 1024 0.20 0.20 37.90 0.00 0.00 0.98 0.00 0.00 +plugin-container 1091 0.36 0.36 84.72 0.00 0.00 1.97 0.00 0.00 +plugin-container 1190 0.35 0.35 86.92 0.00 0.00 2.95 0.00 0.00 +fsnotifier 21921 0.21 0.21 32.94 0.00 0.00 0.00 0.00 0.00 +plugin-container 9001 0.52 0.52 76.73 0.00 0.00 1.97 0.00 0.00 +plugin-container 9190 0.49 0.49 87.71 0.00 0.00 1.97 0.00 0.00 +plugin-container 28295 0.38 0.38 85.60 0.00 0.00 1.97 0.00 0.00 +gamecontrollerd 613 0.25 0.25 50.77 0.00 0.00 0.98 0.00 0.00 +plugin-container 9191 0.37 0.37 84.36 0.00 0.00 1.97 0.00 0.00 +launchservicesd 364 0.22 0.22 52.01 0.00 0.00 0.98 0.00 0.00 +1Password 1021 0.31 0.31 41.60 0.00 0.00 3.93 0.00 0.00 +thermalmonitord 361 0.31 0.32 43.75 0.00 0.00 0.98 0.00 0.00 +askpermissiond 938 0.09 0.09 20.67 0.00 0.00 0.98 0.00 0.00 +ContinuityCaptureAgent 728 0.15 0.15 28.65 0.00 0.00 1.97 0.00 0.00 +appleh13camerad 545 0.12 0.12 29.55 0.00 0.00 0.98 0.00 0.00 +com.apple.WebKit.WebContent 1874 0.18 0.18 58.02 0.00 0.00 0.98 0.00 0.00 +CAReportingService 562 0.07 0.07 37.92 0.00 0.00 0.98 0.00 0.00 +appstoreagent 1107 0.16 0.16 26.86 0.00 0.00 0.98 0.00 0.00 +contextstored 400 0.18 0.18 20.74 0.00 0.00 0.98 0.00 0.00 +akd 731 0.08 0.08 45.70 0.00 0.00 0.98 0.00 0.00 +mDNSResponderHelper 508 0.08 0.08 35.75 0.00 0.00 0.98 0.00 0.00 +AMPArtworkAgent 799 0.11 0.11 71.12 0.00 0.00 0.98 0.00 0.00 +weatherd 1912 0.09 0.09 47.37 0.00 0.00 0.98 0.00 0.00 +photoanalysisd 16189 0.09 0.09 32.44 0.00 0.00 0.98 0.00 0.00 +bookdatastored 9301 0.07 0.07 42.43 0.00 0.00 0.98 0.00 0.00 +nbagent 6922 0.08 0.08 56.92 0.00 0.00 0.98 0.00 0.00 +osqueryd 24140 0.13 0.13 86.31 0.00 0.00 0.98 0.00 0.00 +cloudphotod 1575 0.06 0.06 43.66 0.00 0.00 0.98 0.00 0.00 +storekitagent 800 0.06 0.06 44.65 0.00 0.00 0.98 0.00 0.00 +mlruntimed 1542 0.06 0.06 44.98 0.00 0.00 0.98 0.00 0.00 +newsd 6844 0.06 0.06 45.11 0.00 0.00 0.98 0.00 0.00 +ALL_TASKS -2 1222.65 1222.65 65.70 1161.97 15.81 2875.29 132.40 0.00 + +**** Processor usage **** + +E-Cluster Online: 100% +E-Cluster HW active frequency: 1499 MHz +E-Cluster HW active residency: 67.87% (600 MHz: 0% 972 MHz: 27% 1332 MHz: 24% 1704 MHz: 26% 2064 MHz: 23%) +E-Cluster idle residency: 32.13% +E-Cluster instructions retired: 1.20745e+09 +E-Cluster instructions per clock: 0.703911 +CPU 0 frequency: 1527 MHz +CPU 0 active residency: 54.12% (600 MHz: 0% 972 MHz: 12% 1332 MHz: 15% 1704 MHz: 13% 2064 MHz: 14%) +CPU 0 idle residency: 45.88% +CPU 1 frequency: 1530 MHz +CPU 1 active residency: 55.47% (600 MHz: 0% 972 MHz: 13% 1332 MHz: 15% 1704 MHz: 13% 2064 MHz: 15%) +CPU 1 idle residency: 44.53% + +P0-Cluster Online: 100% +P0-Cluster HW active frequency: 876 MHz +P0-Cluster HW active residency: 16.05% (600 MHz: 62% 828 MHz: 5.7% 1056 MHz: 18% 1296 MHz: 4.9% 1524 MHz: 3.3% 1752 MHz: 1.3% 1980 MHz: 1.5% 2208 MHz: 1.4% 2448 MHz: .39% 2676 MHz: .37% 2904 MHz: 0% 3036 MHz: .07% 3132 MHz: .28% 3168 MHz: .19% 3228 MHz: 1.2%) +P0-Cluster idle residency: 83.95% +P0-Cluster instructions retired: 4.30488e+08 +P0-Cluster instructions per clock: 1.87471 +CPU 2 frequency: 1237 MHz +CPU 2 active residency: 12.66% (600 MHz: 1.6% 828 MHz: .53% 1056 MHz: 5.9% 1296 MHz: 1.9% 1524 MHz: 1.3% 1752 MHz: .40% 1980 MHz: .10% 2208 MHz: .17% 2448 MHz: .01% 2676 MHz: .08% 2904 MHz: 0% 3036 MHz: .01% 3132 MHz: .00% 3168 MHz: .00% 3228 MHz: .62%) +CPU 2 idle residency: 87.34% +CPU 3 frequency: 1066 MHz +CPU 3 active residency: 4.02% (600 MHz: .96% 828 MHz: .46% 1056 MHz: 1.3% 1296 MHz: .68% 1524 MHz: .44% 1752 MHz: .07% 1980 MHz: .02% 2208 MHz: .00% 2448 MHz: .00% 2676 MHz: .03% 2904 MHz: 0% 3036 MHz: .00% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .05%) +CPU 3 idle residency: 95.98% +CPU 4 frequency: 1212 MHz +CPU 4 active residency: 2.01% (600 MHz: .12% 828 MHz: .34% 1056 MHz: .92% 1296 MHz: .26% 1524 MHz: .17% 1752 MHz: .04% 1980 MHz: .05% 2208 MHz: .03% 2448 MHz: .01% 2676 MHz: .01% 2904 MHz: 0% 3036 MHz: .01% 3132 MHz: .01% 3168 MHz: .00% 3228 MHz: .06%) +CPU 4 idle residency: 97.99% +CPU 5 frequency: 1104 MHz +CPU 5 active residency: 0.82% (600 MHz: .02% 828 MHz: .16% 1056 MHz: .46% 1296 MHz: .10% 1524 MHz: .06% 1752 MHz: .00% 1980 MHz: 0% 2208 MHz: .00% 2448 MHz: 0% 2676 MHz: .00% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: .01%) +CPU 5 idle residency: 99.18% + +P1-Cluster Online: 100% +P1-Cluster HW active frequency: 629 MHz +P1-Cluster HW active residency: 0.61% (600 MHz: 94% 828 MHz: 2.1% 1056 MHz: 2.7% 1296 MHz: 1.5% 1524 MHz: .13% 1752 MHz: 0% 1980 MHz: 0% 2208 MHz: 0% 2448 MHz: 0% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: 0%) +P1-Cluster idle residency: 99.39% +P1-Cluster instructions retired: 4.84998e+06 +P1-Cluster instructions per clock: 0.692523 +CPU 6 frequency: 962 MHz +CPU 6 active residency: 0.56% (600 MHz: .07% 828 MHz: .21% 1056 MHz: .17% 1296 MHz: .11% 1524 MHz: .00% 1752 MHz: 0% 1980 MHz: 0% 2208 MHz: 0% 2448 MHz: 0% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: 0%) +CPU 6 idle residency: 99.44% +CPU 7 frequency: 1074 MHz +CPU 7 active residency: 0.10% (600 MHz: .01% 828 MHz: .01% 1056 MHz: .06% 1296 MHz: .02% 1524 MHz: .00% 1752 MHz: 0% 1980 MHz: 0% 2208 MHz: 0% 2448 MHz: 0% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: 0%) +CPU 7 idle residency: 99.90% +CPU 8 frequency: 1245 MHz +CPU 8 active residency: 0.02% (600 MHz: 0% 828 MHz: .00% 1056 MHz: .00% 1296 MHz: .02% 1524 MHz: .00% 1752 MHz: 0% 1980 MHz: 0% 2208 MHz: 0% 2448 MHz: 0% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: 0%) +CPU 8 idle residency: 99.98% +CPU 9 frequency: 1289 MHz +CPU 9 active residency: 0.02% (600 MHz: 0% 828 MHz: 0% 1056 MHz: .00% 1296 MHz: .02% 1524 MHz: .00% 1752 MHz: 0% 1980 MHz: 0% 2208 MHz: 0% 2448 MHz: 0% 2676 MHz: 0% 2904 MHz: 0% 3036 MHz: 0% 3132 MHz: 0% 3168 MHz: 0% 3228 MHz: 0%) +CPU 9 idle residency: 99.98% + +System instructions retired: 1.64279e+09 +System instructions per clock: 0.841601 +CPU Power: 211 mW +GPU Power: 147 mW +ANE Power: 0 mW +Combined Power (CPU + GPU + ANE): 359 mW \ No newline at end of file From e7f41802b1b1c763b72b8f3d8f7d5d462ee613b1 Mon Sep 17 00:00:00 2001 From: Arjan Lamers Date: Tue, 23 Jan 2024 16:08:05 +0100 Subject: [PATCH 4/4] minor formatting and comment fixes --- .../joularjx/cpu/PowermetricsMacOS.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java index 3c75d2c..1164885 100644 --- a/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java +++ b/src/main/java/org/noureddine/joularjx/cpu/PowermetricsMacOS.java @@ -23,10 +23,10 @@ public class PowermetricsMacOS implements Cpu { @Override public void initialize() { - if(initialized) { + if (initialized) { return; } - + try { // todo: detect when sudo fails as this currently won't throw an exception process = Runtime.getRuntime().exec("sudo powermetrics --samplers cpu_power -i 1000"); @@ -42,7 +42,7 @@ public void initialize() { void readHeader() throws IOException { BufferedReader reader = getReader(); - for (int i=0; i<6; i++) { + for (int i = 0; i < 6; i++) { String line = reader.readLine(); if (line.startsWith("EFI version")) { intelCpu = true; @@ -76,7 +76,7 @@ private double getCurrentPowerIntel() { continue; } - // ofor Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern + // for Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern final var i = line.indexOf(POWER_INDICATOR_INTEL_CHIP); if (i >= 0) { powerInWatts += Double.parseDouble(line.substring(i + POWER_INDICATOR_INTEL_CHIP.length(), line.indexOf('W'))); @@ -103,11 +103,10 @@ public double getCurrentPowerM() { } // looking for line fitting the: " Power: xxx mW" pattern and add all of the associated values together - // or, for Intel chips, the: "Intel energy model derived package power (CPUs+GT+SA): xxx W" pattern - final var i = line.indexOf(POWER_INDICATOR_M_CHIP); - if (i >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { - powerInMilliwatts += Integer.parseInt(line.substring(i + POWER_INDICATOR_M_CHIP.length(), line.indexOf('m') - 1)); - } + final var i = line.indexOf(POWER_INDICATOR_M_CHIP); + if (i >= 0 && '-' != line.charAt(1) && !line.startsWith("Combined")) { + powerInMilliwatts += Integer.parseInt(line.substring(i + POWER_INDICATOR_M_CHIP.length(), line.indexOf('m') - 1)); + } } return (double) powerInMilliwatts / 1000; } catch (IOException e) {