1
0
mirror of https://github.com/taigrr/log-socket synced 2026-03-21 14:12:18 -07:00

test(log): add comprehensive benchmarks

Adds a new benchmark_test.go file with comprehensive benchmarks for the logging library:

Serial benchmarks:
- Trace, Debug, Info, Notice, Warn, Error levels

Formatted logging:
- Debugf, Infof, Errorf variants

Parallel benchmarks:
- DebugParallel, InfoParallel, InfofParallel

Logger instance (namespaced):
- LoggerInfo, LoggerInfof, LoggerDebugParallel

Multiple clients/namespaces:
- MultipleClients, MultipleNamespaces

Message size comparison:
- Short, Medium, Long messages

Level filtering overhead:
- DebugFilteredByLevel

Also removes the duplicate BenchmarkDebugSerial from log_test.go and applies minor whitespace formatting fixes.

Fixes #6
This commit is contained in:
2026-02-10 08:04:08 +00:00
parent 93dd230be0
commit 085aadaaef
5 changed files with 397 additions and 24 deletions

View File

@@ -2,7 +2,6 @@ package log
import (
"strconv"
"sync"
"testing"
)
@@ -37,21 +36,6 @@ func TestSetLogLevel(t *testing.T) {
c.Destroy()
}
func BenchmarkDebugSerial(b *testing.B) {
c := CreateClient("test")
var x sync.WaitGroup
x.Add(b.N)
for i := 0; i < b.N; i++ {
Debug(i)
go func() {
c.Get()
x.Done()
}()
}
x.Wait()
c.Destroy()
}
// Trace ensure logs come out in the right order
func TestOrder(t *testing.T) {
testString := "Testing trace: "