forked from djherbis/times
-
Notifications
You must be signed in to change notification settings - Fork 1
/
bench_test.go
65 lines (57 loc) · 978 Bytes
/
bench_test.go
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package times
import (
"os"
"testing"
)
func BenchmarkGet(t *testing.B) {
fileTest(t, func(f *os.File) {
fi, err := os.Stat(f.Name())
if err != nil {
t.Error(err)
}
for i := 0; i < t.N; i++ {
Get(fi)
}
})
t.ReportAllocs()
}
func BenchmarkStatFile(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
StatFile(f)
}
})
t.ReportAllocs()
}
func BenchmarkStat(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
Stat(f.Name())
}
})
t.ReportAllocs()
}
func BenchmarkLstat(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
Lstat(f.Name())
}
})
t.ReportAllocs()
}
func BenchmarkOsStat(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
os.Stat(f.Name())
}
})
t.ReportAllocs()
}
func BenchmarkOsLstat(t *testing.B) {
fileTest(t, func(f *os.File) {
for i := 0; i < t.N; i++ {
os.Lstat(f.Name())
}
})
t.ReportAllocs()
}