From 9a445d5f6aa07ca0797b7571c644a95d2be54716 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Fri, 16 Aug 2019 19:06:18 +0200 Subject: [PATCH] [process][windows] Use win32 API in process.NumThreads() instead of slow WMI call --- process/process_windows.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/process/process_windows.go b/process/process_windows.go index 056edc1..f8610a8 100644 --- a/process/process_windows.go +++ b/process/process_windows.go @@ -520,11 +520,11 @@ func (p *Process) NumThreads() (int32, error) { } func (p *Process) NumThreadsWithContext(ctx context.Context) (int32, error) { - dst, err := GetWin32ProcWithContext(ctx, p.Pid) + _, ret, _, err := getFromSnapProcess(p.Pid) if err != nil { return 0, fmt.Errorf("could not get ThreadCount: %s", err) } - return int32(dst[0].ThreadCount), nil + return ret, nil } func (p *Process) Threads() (map[int32]*cpu.TimesStat, error) { return p.ThreadsWithContext(context.Background())