-
Notifications
You must be signed in to change notification settings - Fork 1
/
writer_test.go
43 lines (38 loc) · 1.01 KB
/
writer_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
package logger
import "testing"
func BenchmarkEnableDirect(b *testing.B) {
consoleEnabler := func(l Level, scope string) bool {
switch scope {
case "ice", "sctp", "dtls", "datachannel":
return l > WarnLevel
default:
return true
}
}
// influxEnabler := func(l log.Level, s string) bool { return l >= log.ErrorLevel }
stackEnabler := func(l Level, scope string) bool {
return l >= ErrorLevel
}
w := ConsoleWriter(false, consoleEnabler, stackEnabler)
for i := 0; i < b.N; i++ {
w.enablerFn(WarnLevel, "ice")
}
}
func BenchmarkEnableMap(b *testing.B) {
consoleEnabler := func(l Level, scope string) bool {
switch scope {
case "ice", "sctp", "dtls", "datachannel":
return l > WarnLevel
default:
return true
}
}
// influxEnabler := func(l log.Level, s string) bool { return l >= log.ErrorLevel }
stackEnabler := func(l Level, scope string) bool {
return l >= ErrorLevel
}
w := ConsoleWriter(false, consoleEnabler, stackEnabler)
for i := 0; i < b.N; i++ {
w.isEnable(WarnLevel, "ice")
}
}