...
1 package ini
2
3 import (
4 "testing"
5 )
6
7 func newTestFile(block bool) *File {
8 c, _ := Load([]byte(confData))
9 c.BlockMode = block
10 return c
11 }
12
13 func Benchmark_Key_Value(b *testing.B) {
14 c := newTestFile(true)
15 for i := 0; i < b.N; i++ {
16 c.Section("").Key("NAME").Value()
17 }
18 }
19
20 func Benchmark_Key_Value_NonBlock(b *testing.B) {
21 c := newTestFile(false)
22 for i := 0; i < b.N; i++ {
23 c.Section("").Key("NAME").Value()
24 }
25 }
26
27 func Benchmark_Key_Value_ViaSection(b *testing.B) {
28 c := newTestFile(true)
29 sec := c.Section("")
30 for i := 0; i < b.N; i++ {
31 sec.Key("NAME").Value()
32 }
33 }
34
35 func Benchmark_Key_Value_ViaSection_NonBlock(b *testing.B) {
36 c := newTestFile(false)
37 sec := c.Section("")
38 for i := 0; i < b.N; i++ {
39 sec.Key("NAME").Value()
40 }
41 }
42
43 func Benchmark_Key_Value_Direct(b *testing.B) {
44 c := newTestFile(true)
45 key := c.Section("").Key("NAME")
46 for i := 0; i < b.N; i++ {
47 key.Value()
48 }
49 }
50
51 func Benchmark_Key_Value_Direct_NonBlock(b *testing.B) {
52 c := newTestFile(false)
53 key := c.Section("").Key("NAME")
54 for i := 0; i < b.N; i++ {
55 key.Value()
56 }
57 }
58
59 func Benchmark_Key_String(b *testing.B) {
60 c := newTestFile(true)
61 for i := 0; i < b.N; i++ {
62 _ = c.Section("").Key("NAME").String()
63 }
64 }
65
66 func Benchmark_Key_String_NonBlock(b *testing.B) {
67 c := newTestFile(false)
68 for i := 0; i < b.N; i++ {
69 _ = c.Section("").Key("NAME").String()
70 }
71 }
72
73 func Benchmark_Key_String_ViaSection(b *testing.B) {
74 c := newTestFile(true)
75 sec := c.Section("")
76 for i := 0; i < b.N; i++ {
77 _ = sec.Key("NAME").String()
78 }
79 }
80
81 func Benchmark_Key_String_ViaSection_NonBlock(b *testing.B) {
82 c := newTestFile(false)
83 sec := c.Section("")
84 for i := 0; i < b.N; i++ {
85 _ = sec.Key("NAME").String()
86 }
87 }
88
89 func Benchmark_Key_SetValue(b *testing.B) {
90 c := newTestFile(true)
91 for i := 0; i < b.N; i++ {
92 c.Section("").Key("NAME").SetValue("10")
93 }
94 }
95
96 func Benchmark_Key_SetValue_VisSection(b *testing.B) {
97 c := newTestFile(true)
98 sec := c.Section("")
99 for i := 0; i < b.N; i++ {
100 sec.Key("NAME").SetValue("10")
101 }
102 }
103
View as plain text