-
Notifications
You must be signed in to change notification settings - Fork 0
/
logs_test.go
72 lines (60 loc) · 1.92 KB
/
logs_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
package gohan_logs_benchmark
import (
"testing"
"github.com/cloudwan/gohan/log"
"github.com/cloudwan/gohan/util"
)
func BenchmarkNewLogger(b *testing.B) {
for n := 0; n < b.N; n++ {
log.NewLogger()
}
}
func BenchmarkNewLoggerForModule(b *testing.B) {
for n := 0; n < b.N; n++ {
log.NewLoggerForModule("gohan.module.name")
}
}
func BenchmarkLogNoFormat(b *testing.B) {
cfg := util.GetConfig()
if err := cfg.ReadConfig("devNullLog.yaml"); err != nil {
panic(err)
}
log.SetUpLogging(cfg)
logger := log.NewLoggerForModule("gohan.module.name")
for n := 0; n < b.N; n++ {
logger.Info("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
}
}
func BenchmarkLogWithFormat(b *testing.B) {
cfg := util.GetConfig()
if err := cfg.ReadConfig("devNullLog.yaml"); err != nil {
panic(err)
}
log.SetUpLogging(cfg)
logger := log.NewLoggerForModule("gohan.module.name")
for n := 0; n < b.N; n++ {
logger.Info("Number: %d, string: %s", 42, "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
}
}
func BenchmarkEachLogCreatesNewLogger(b *testing.B) {
cfg := util.GetConfig()
if err := cfg.ReadConfig("devNullLog.yaml"); err != nil {
panic(err)
}
log.SetUpLogging(cfg)
for n := 0; n < b.N; n++ {
logger := log.NewLogger()
logger.Info("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
}
}
func BenchmarkEachLogCreatesNewLoggerForModule(b *testing.B) {
cfg := util.GetConfig()
if err := cfg.ReadConfig("devNullLog.yaml"); err != nil {
panic(err)
}
log.SetUpLogging(cfg)
for n := 0; n < b.N; n++ {
logger := log.NewLoggerForModule("gohan.module.name")
logger.Info("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.")
}
}