-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
io_test.go
131 lines (108 loc) · 2.38 KB
/
io_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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package gocostmodel
import (
"fmt"
"io/ioutil"
"testing"
)
type stringer int
func (s stringer) String() string {
return "a"
}
var (
st stringer = 1
bl = true
ptr = &st
)
// fmt.Fprintx(ioutil.Discard, ...) benchmarks the fmt mechanism, but not
// the actual I/O, since Discard doesn't write anywhere.
func BenchmarkPrintln(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintln(ioutil.Discard, "test")
}
}
func BenchmarkEmptyPrint(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprint(ioutil.Discard, "")
}
}
func BenchmarkPrintPctd(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%d", i)
}
}
func BenchmarkPrintPctb(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%b", i)
}
}
func BenchmarkPrintPctc(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%c", i1)
}
}
func BenchmarkPrintPcto(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%o", i)
}
}
func BenchmarkPrintPctxInt(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%x", i)
}
}
func BenchmarkPrintPctU(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%U", i1)
}
}
func BenchmarkPrintPcts(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%s", "a")
}
}
func BenchmarkPrintPctq(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%q", "a")
}
}
func BenchmarkPrintPctxString(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%x", "a")
}
}
func BenchmarkPrintPctxByte(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%x", 'a')
}
}
func BenchmarkPrintPctt(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%t", bl)
}
}
func BenchmarkPrintPctT(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%T", "a")
}
}
func BenchmarkPrintPctf(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%f", d1)
}
}
func BenchmarkPrintPcte(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%e", d1)
}
}
func BenchmarkPrintPctp(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%p", ptr)
}
}
// note that stringer.String gets inlined.
func BenchmarkPrintStringer(b *testing.B) {
for i := 0; i < b.N; i++ {
fmt.Fprintf(ioutil.Discard, "%s", st)
}
}