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

Incorrect Percent With Context output on Windows 11, version 23H2 #1744

Open
1 task
sha1sof opened this issue Nov 11, 2024 · 0 comments
Open
1 task

Incorrect Percent With Context output on Windows 11, version 23H2 #1744

sha1sof opened this issue Nov 11, 2024 · 0 comments

Comments

@sha1sof
Copy link

sha1sof commented Nov 11, 2024

Describe the bug
Incorrect values of the CPU utilization percentage on Windows are displayed

To Reproduce

package main

import (
	"context"
	"fmt"
	"github.com/shirou/gopsutil/cpu"
	"time"
)

func main() {

	for {
		ctx, cancle := context.WithTimeout(context.Background(), 2*time.Second)
		defer cancle()
		usage, err := cpu.PercentWithContext(ctx, 1*time.Second, false)
		if err != nil {
			fmt.Println(err)
			continue
		}
		fmt.Println("usage:", usage[0])
	}
}

Expected behavior
image

Environment (please complete the following information):

  • Windows:Windows 11, version 23H2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant