-
Notifications
You must be signed in to change notification settings - Fork 2
/
daslog_bench_test.go
63 lines (51 loc) · 1.06 KB
/
daslog_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
package daslog
import (
"bytes"
"log"
"testing"
)
func BenchmarkLog(b *testing.B) {
var buf bytes.Buffer
l := log.New(&buf, "test", log.LstdFlags)
for i := 0; i < b.N; i++ {
l.Printf("test %s", "message")
}
}
func BenchmarkDaslogPurePrefix(b *testing.B) {
var buf bytes.Buffer
o := Options{
Destination: &buf,
Prefix: "test",
LogLevel: UrgencyLevelCritical,
}
l, _ := New(o)
for i := 0; i < b.N; i++ {
l.Infof("test %s", "message")
}
}
// template prefix without a {{.Q}} option
func BenchmarkDaslogTemplatePrefix(b *testing.B) {
var buf bytes.Buffer
o := Options{
Destination: &buf,
Prefix: "{{.O}}: ",
LogLevel: UrgencyLevelCritical,
}
l, _ := New(o)
for i := 0; i < b.N; i++ {
l.Infof("test %s", "message")
}
}
// template prefix with a {{.Q}} option
func BenchmarkDaslogTemplatePrefixQ(b *testing.B) {
var buf bytes.Buffer
o := Options{
Destination: &buf,
Prefix: "{{.O}} [{{.Q}}]: ",
LogLevel: UrgencyLevelCritical,
}
l, _ := New(o)
for i := 0; i < b.N; i++ {
l.Infof("test %s", "message")
}
}