-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathpidusage_test.go
More file actions
34 lines (29 loc) · 723 Bytes
/
pidusage_test.go
File metadata and controls
34 lines (29 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package pidusage
import (
"os"
"testing"
)
var pid = os.Getpid()
func BenchmarkGetStat(b *testing.B) {
for i := 0; i < b.N; i++ {
GetStat(pid)
}
}
// Before optimize
// $ go clean -testcache && go test -test.v -bench=BenchmarkGetStat
// goos: linux
// goarch: amd64
// pkg: github.com/struCoder/pidusage
// BenchmarkGetStat
// BenchmarkGetStat-12 470 2690727 ns/op
// PASS
// ok github.com/struCoder/pidusage 1.533s
// After optimize
// $ go clean -testcache && go test -test.v -bench=BenchmarkGetStat
// goos: linux
// goarch: amd64
// pkg: github.com/struCoder/pidusage
// BenchmarkGetStat
// BenchmarkGetStat-12 28416 36234 ns/op
// PASS
// ok github.com/struCoder/pidusage 1.472s