-
Notifications
You must be signed in to change notification settings - Fork 2
/
dlog_test.go
54 lines (45 loc) · 914 Bytes
/
dlog_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
package dlog
import (
"testing"
"time"
)
type NullWriter struct {}
func (NullWriter) Write(data []byte) (int, error) {
return len(data), nil
}
func TestLogger(t *testing.T) {
SetOption(OPT_ALTERR|OPT_ALTOUT|OPT_TCP)
nw := NullWriter{}
SetAltWriter(nw)
Log(ERROR, "%g", 12345.67890)
SetAltWriter(nil)
Log(ERROR, "%g", 12345.67890)
}
func BenchmarkLog(b *testing.B) {
nw := NullWriter{}
SetAltWriter(nw)
SetOption(OPT_NONET|OPT_ALTOUT)
for i := 0; i < b.N; i++ {
Log(ERROR, "%g", 12345.67890)
}
}
func BenchmarkTimeString(b *testing.B) {
t := time.Now()
for i := 0; i < b.N; i++ {
TimeString(t)
}
}
func BenchmarkTimeBuffer(b *testing.B) {
t := time.Now()
for i := 0; i < b.N; i++ {
var buf [24]byte
TimeBuffer(buf[:], t, true)
}
}
func BenchmarkTimeBufferNoZone(b *testing.B) {
t := time.Now()
for i := 0; i < b.N; i++ {
var buf [24]byte
TimeBuffer(buf[:], t, false)
}
}