Skip to content

test(log): add comprehensive benchmarks#17

Closed
taigrr wants to merge 1 commit into
masterfrom
cd/6-add-benchmarks
Closed

test(log): add comprehensive benchmarks#17
taigrr wants to merge 1 commit into
masterfrom
cd/6-add-benchmarks

Conversation

@taigrr
Copy link
Copy Markdown
Owner

@taigrr taigrr commented Feb 10, 2026

Summary

Adds comprehensive benchmarks for the log-socket library to help measure performance and track regressions.

Fixes #6

Benchmarks Added

Serial Benchmarks (Single Log Levels)

  • BenchmarkTrace, BenchmarkDebug, BenchmarkInfo
  • BenchmarkNotice, BenchmarkWarn, BenchmarkError

Formatted Logging

  • BenchmarkDebugf, BenchmarkInfof, BenchmarkErrorf

Parallel Benchmarks

  • BenchmarkDebugParallel, BenchmarkInfoParallel, BenchmarkInfofParallel

Logger Instance (Namespaced Logging)

  • BenchmarkLoggerInfo, BenchmarkLoggerInfof, BenchmarkLoggerDebugParallel

Multiple Clients/Namespaces

  • BenchmarkMultipleClients - measures overhead with multiple consumers
  • BenchmarkMultipleNamespaces - measures namespaced logging performance

Message Size Comparison

  • BenchmarkInfoShortMessage - 2 chars
  • BenchmarkInfoMediumMessage - ~60 chars
  • BenchmarkInfoLongMessage - ~250 chars

Level Filtering Overhead

  • BenchmarkDebugFilteredByLevel - measures overhead when logs are filtered

Sample Results (2 cores)

BenchmarkTrace-2                      56664       2556 ns/op
BenchmarkDebug-2                      48211       2351 ns/op
BenchmarkInfo-2                       41882       2573 ns/op
BenchmarkDebugf-2                     66877       2323 ns/op
BenchmarkInfoParallel-2               48004       2208 ns/op
BenchmarkLoggerInfo-2                 95398       1275 ns/op
BenchmarkLoggerDebugParallel-2       182540        619 ns/op
BenchmarkMultipleNamespaces-2        106291       1086 ns/op

Other Changes

  • Moved duplicate BenchmarkDebugSerial from log_test.go to the new benchmark file
  • Minor whitespace formatting fixes from goimports

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
@taigrr taigrr closed this Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add benchmarks

1 participant