Skip to content
New issue

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

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

Already on GitHub? # 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
# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

2 participants