//go:build windows package game import ( "errors" "testing" "time" ) // TestGPUEngineSamplerLive opens the real PDH query and takes two samples; // the first only primes the rate counters. Skipped (not failed) when the // machine has no GPU counters. func TestGPUEngineSamplerLive(t *testing.T) { s, err := openGPUEngineSampler() if err != nil { t.Skipf("no GPU engine counters: %v", err) } if _, err := s.sample(); !errors.Is(err, errNotPrimed) { t.Fatalf("first sample: err = %v, want errNotPrimed", err) } time.Sleep(200 * time.Millisecond) utils, err := s.sample() if err != nil { t.Fatalf("second sample: %v", err) } for pid, util := range utils { if pid < 0 || util < 0 { t.Errorf("pid %d: util %.2f", pid, util) } } t.Logf("%d processes with 3D-engine usage", len(utils)) }