3 Star 2 Fork 1

Gitee 极速下载/Go-Logger

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/phachon/go-logger
克隆/下载
benchmark_test.go 2.26 KB
一键复制 编辑 原始数据 按行查看 历史
phachon 提交于 2019-12-15 11:20 . update go mod
package go_logger
import (
"testing"
)
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="ConsoleText"
func BenchmarkLoggerConsoleText(b *testing.B) {
logger := NewLogger()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
}
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="ConsoleAsyncText"
func BenchmarkLoggerConsoleAsyncText(b *testing.B) {
logger := NewLogger()
logger.SetAsync()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
logger.Flush()
}
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="ConsoleJson"
func BenchmarkLoggerConsoleJson(b *testing.B) {
logger := NewLogger()
logger.Detach("console")
logger.Attach("console", LOGGER_LEVEL_DEBUG, &ConsoleConfig{
JsonFormat: true,
})
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
}
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="FileText"
func BenchmarkLoggerFileText(b *testing.B) {
logger := NewLogger()
logger.Detach("console")
logger.Attach("file", LOGGER_LEVEL_DEBUG, &FileConfig{
Filename: "./test.log",
DateSlice: "d",
})
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
}
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="AsyncText"
func BenchmarkLoggerFileAsyncText(b *testing.B) {
logger := NewLogger()
logger.Detach("console")
logger.Attach("file", LOGGER_LEVEL_DEBUG, &FileConfig{
Filename: "./test.log",
DateSlice: "d",
})
logger.SetAsync()
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
logger.Flush()
}
// go test -run=benchmark -cpu=1,2,4 -benchmem -benchtime=3s -bench="FileJson"
func BenchmarkLoggerFileJson(b *testing.B) {
logger := NewLogger()
logger.Detach("console")
logger.Attach("file", LOGGER_LEVEL_DEBUG, &FileConfig{
Filename: "./test.log",
DateSlice: "d",
JsonFormat: true,
})
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
logger.Info("benchmark logger message")
}
})
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors/Go-Logger.git
git@gitee.com:mirrors/Go-Logger.git
mirrors
Go-Logger
Go-Logger
master

搜索帮助