File: bench_test.go

package info (click to toggle)
golang-github-djherbis-times 1.6.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 184 kB
  • sloc: sh: 10; makefile: 3
file content (65 lines) | stat: -rw-r--r-- 978 bytes parent folder | download | duplicates (2)
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()
}