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 Oct 1, 2020
1 parent 64ba9d0 commit eaa3481
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions process/process_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,3 +662,24 @@ 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 eaa3481

Please sign in to comment.