Skip to content

Commit

Permalink
[process] Add benchmarks for New(), Name() Ppid()
Browse files Browse the repository at this point in the history
run only them with: go test -bench=. -run=xxx github.com/shirou/gopsutil/process
  • Loading branch information
Lomanic committed Sep 29, 2020
1 parent 64ba9d0 commit 041e031
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,23 @@ func Test_AllProcesses_cmdLine(t *testing.T) {
}
}
}
func BenchmarkNewProcess(b *testing.B) {
checkPid := os.Getpid()
for i := 0; i < b.N; i++ {
NewProcess(int32(checkPid))
}
}

func BenchmarkProcessName(b *testing.B) {
p := testGetProcess()
for i := 0; i < b.N; i++ {
p.Name()
}
}

func BenchmarkProcessPpid(b *testing.B) {
p := testGetProcess()
for i := 0; i < b.N; i++ {
p.Ppid()
}
}

0 comments on commit 041e031

Please sign in to comment.