Skip to content

Commit 346766a

Browse files
committed
fix: add 1.1s PDH warmup poll at startup so CPU% shows real data from frame 1
1 parent 3151000 commit 346766a

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

  • examples/Demo/src/main/java/fasthardware

examples/Demo/src/main/java/fasthardware/Demo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ public void run() {
179179
System.out.print(ALT_ON + HIDE_CURSOR);
180180
System.out.flush();
181181

182+
// Warm-up: PDH CPU counters need one interval before returning real data
183+
try {
184+
hw.getSnapshot();
185+
Thread.sleep(1100);
186+
} catch (Throwable ignored) {}
187+
182188
// Try to detect terminal width
183189
int termW = 120;
184190
try {

0 commit comments

Comments
 (0)