1 Star 0 Fork 0

FlyingOnion/wtflog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
json_logger_bench_test.go 2.71 KB
一键复制 编辑 原始数据 按行查看 历史
FlyingOnion 提交于 2022-05-24 10:24 . add json logger, update tests
package wtflog_test
import (
"io"
"testing"
. "gitee.com/FlyingOnion/wtflog"
. "gitee.com/FlyingOnion/wtflog/types"
)
func BenchmarkJLog1Int(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(Int(1))
}
}
func BenchmarkJLog1int(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(1)
}
}
func BenchmarkJLog5Ints(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(Int(1), Int(2), Int(3), Int(4), Int(5))
}
}
func BenchmarkJLog5ints(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(1, 2, 3, 4, 5)
}
}
func BenchmarkJLog10Ints(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(Int(1), Int(2), Int(3), Int(4), Int(5),
Int(1), Int(2), Int(3), Int(4), Int(5))
}
}
func BenchmarkJLog10ints(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(1, 2, 3, 4, 5, 1, 2, 3, 4, 5)
}
}
// func BenchmarkJLog5Strings(b *testing.B) {
// l := New(WithWriter(io.Discard), WithLevel(LevelInfo))
// b.ResetTimer()
// for i := 0; i < b.N; i++ {
// l.Info(String("aaa"), String("bbb"), String("ccc"), String("ddd"), String("eee"))
// }
// }
func BenchmarkJLog5strings(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info("aaa", "bbb", "ccc", "ddd", "eee")
}
}
// func BenchmarkJ10Strings(b *testing.B) {
// l := New(WithWriter(io.Discard), WithLevel(LevelInfo))
// b.ResetTimer()
// for i := 0; i < b.N; i++ {
// l.Info(String("aaa"), String("bbb"), String("ccc"), String("ddd"), String("eee"),
// String("aaa"), String("bbb"), String("ccc"), String("ddd"), String("eee"))
// }
// }
func BenchmarkJLog10strings(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info("aaa", "bbb", "ccc", "ddd", "eee",
"aaa", "bbb", "ccc", "ddd", "eee")
}
}
func BenchmarkJLog1Struct(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
a := A{"S", 3, []B{{"A", []string{"a"}}}}
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(a)
}
}
func BenchmarkJLog5StructsWithoutGen(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
a := A{"S", 3, []B{{"A", []string{"a"}}}}
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(a, a, a, a, a)
}
}
func BenchmarkJLog5StructsWithGen(b *testing.B) {
l := NewJsonLogger().WithWriter(io.Discard)
a := AA{"S", 3, []BB{{"A", []string{"a"}}}}
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Info(a, a, a, a, a)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/FlyingOnion/wtflog.git
git@gitee.com:FlyingOnion/wtflog.git
FlyingOnion
wtflog
wtflog
master

搜索帮助