-
Notifications
You must be signed in to change notification settings - Fork 4
/
tlz_test.go
53 lines (39 loc) · 1.27 KB
/
tlz_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 tlog_test
import (
"io"
"testing"
"tlog.app/go/eazy"
"tlog.app/go/tlog"
"tlog.app/go/tlog/tlio"
)
func BenchmarkLogCompressOneline(b *testing.B) {
b.ReportAllocs()
var full, small tlio.CountingIODiscard
w := eazy.NewWriter(&small, 128*1024, 1024)
l := tlog.New(io.MultiWriter(&full, w))
tr := l.Start("span_name")
types := []string{"type_a", "value_b", "qweqew", "asdads"}
for i := 0; i < b.N; i++ {
// tr := l.Start("span_name")
tr.Printw("some example message", "i", i, "type", types[i%len(types)])
// tr.Finish()
}
b.SetBytes(full.Bytes.Load() / int64(b.N))
b.ReportMetric(float64(full.Bytes.Load())/float64(small.Bytes.Load()), "ratio")
}
func BenchmarkLogCompressOnelineText(b *testing.B) {
b.ReportAllocs()
var full, small tlio.CountingIODiscard
w := eazy.NewWriter(&small, 128*1024, 1024)
cw := tlog.NewConsoleWriter(io.MultiWriter(&full, w), tlog.LstdFlags)
l := tlog.New(cw)
tr := l.Start("span_name")
types := []string{"type_a", "value_b", "qweqew", "asdads"}
for i := 0; i < b.N; i++ {
// tr := l.Start("span_name")
tr.Printw("some example message", "i", i, "type", types[i%len(types)])
// tr.Finish()
}
b.SetBytes(full.Bytes.Load() / int64(b.N))
b.ReportMetric(float64(full.Bytes.Load())/float64(small.Bytes.Load()), "ratio")
}