1
0
mirror of https://github.com/taigrr/log-socket synced 2026-03-21 08:22: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

10
main.go
View File

@@ -17,21 +17,21 @@ func generateLogs() {
apiLogger := logger.NewLogger("api")
dbLogger := logger.NewLogger("database")
authLogger := logger.NewLogger("auth")
for {
logger.Info("This is a default namespace log!")
apiLogger.Info("API request received")
apiLogger.Debug("Processing API call")
dbLogger.Info("Database query executed")
dbLogger.Warn("Slow query detected")
authLogger.Info("User authentication successful")
authLogger.Error("Failed login attempt detected")
logger.Trace("This is a trace log in default namespace!")
logger.Warn("This is a warning in default namespace!")
time.Sleep(2 * time.Second)
}
}