Benchmark before this change (process.NewProcess() calls process.PidExistsWithContext()
internally)
go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
goos: linux
goarch: amd64
pkg: github.com/shirou/gopsutil/process
BenchmarkNewProcess-4 14722 78751 ns/op
PASS
ok github.com/shirou/gopsutil/process 3.685s
Benchmark with this change applied
go test -bench=BenchmarkNewProcess github.com/shirou/gopsutil/process
goos: linux
goarch: amd64
pkg: github.com/shirou/gopsutil/process
BenchmarkNewProcess-4 14835 80180 ns/op
PASS
ok github.com/shirou/gopsutil/process 3.761s
* All context-less wrapping functions (the ones without WithContext
suffix) were moved into process.go since they all are the same.
* Call context is now passed to all underlying functions in
*WithContext() functions.
* All common *BSD bits were moved to process_bsd.go.
* Process.Tgid() method lacked a WithContext counterpart, so
Process.TgidWithContext() was added for uniformity.
* NewProcessWithContext() function was added since NewProcess() is
used a lot throughout the module, and there is no way to pass a
context to it.
This is a part of #761 effort.