Files
tasks/common/log/zap_logger_bench_test.go
zeekay 5a601d081b rebrand: go.temporal.io/server -> github.com/hanzoai/tasks
Full module path rebrand from Temporal to Hanzo Tasks:
- go.mod module: github.com/hanzoai/tasks
- All internal Go imports updated (1906 files)
- cmd/server renamed to cmd/tasksd
- Binary name: tasksd (was temporal-server)
- Docker images: hanzoai/tasks (was temporalio/server)
- README rewritten with Hanzo Tasks branding
- LLM.md created with integration notes
- Makefile, goreleaser, CI workflows updated
- go.temporal.io/sdk and go.temporal.io/api imports preserved (separate repos)

Fork of Temporal.io (MIT license).
2026-03-19 10:36:40 -07:00

71 lines
3.4 KiB
Go

package log
import (
"testing"
"github.com/hanzoai/tasks/common/log/tag"
"go.uber.org/zap"
)
/**
$ go test -v -bench=. | grep -E "(Bench)|(ns/op)"
BenchmarkZapLoggerWithFields
BenchmarkZapLoggerWithFields-4 152793 7200 ns/op
BenchmarkLoggerWithFields
BenchmarkLoggerWithFields-4 146850 8370 ns/op
BenchmarkZapLoggerWithoutFields
BenchmarkZapLoggerWithoutFields-4 192972 5885 ns/op
BenchmarkLoggerWithoutFields
BenchmarkLoggerWithoutFields-4 162109 7211 ns/op
*/
func BenchmarkZapLoggerWithFields(b *testing.B) {
zLogger := buildZapLogger(Config{Level: "info"}, false)
for i := 0; i < b.N; i++ {
zLoggerWith := zLogger.With(zap.Int64("wf-schedule-id", int64(i)), zap.String("cluster-name", "this is a very long value: 1234567890 1234567890 1234567890 1234567890"))
zLoggerWith.Info("msg to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
zap.String("wf-namespace", "test-namespace"))
zLoggerWith.Debug("msg NOT to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
zap.String("wf-namespace", "test-namespace"))
}
}
func BenchmarkLoggerWithFields(b *testing.B) {
logger := NewZapLogger(buildZapLogger(Config{Level: "info"}, true))
for i := 0; i < b.N; i++ {
loggerWith := logger.With(tag.WorkflowScheduledEventID(int64(i)), tag.ClusterName("this is a very long value: 1234567890 1234567890 1234567890 1234567890"))
loggerWith.Info("msg to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
tag.WorkflowNamespace("test-namespace"))
loggerWith.Debug("msg NOT to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
tag.WorkflowNamespace("test-namespace"))
}
}
func BenchmarkZapLoggerWithoutFields(b *testing.B) {
zLogger := buildZapLogger(Config{Level: "info"}, false)
for i := 0; i < b.N; i++ {
zLogger.Info("msg to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
zap.Int64("wf-schedule-id", int64(i)), zap.String("cluster-name", "this is a very long value: 1234567890 1234567890 1234567890 1234567890"),
zap.String("wf-namespace", "test-namespace"))
zLogger.Debug("msg NOT to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
zap.Int64("wf-schedule-id", int64(i)), zap.String("cluster-name", "this is a very long value: 1234567890 1234567890 1234567890 1234567890"),
zap.String("wf-namespace", "test-namespace"))
}
}
func BenchmarkLoggerWithoutFields(b *testing.B) {
logger := NewZapLogger(buildZapLogger(Config{Level: "info"}, true))
for i := 0; i < b.N; i++ {
logger.Info("msg to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
tag.WorkflowNamespace("test-namespace"),
tag.WorkflowScheduledEventID(int64(i)), tag.ClusterName("this is a very long value: 1234567890 1234567890 1234567890 1234567890"))
logger.Debug("msg NOT to print log, 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890 1234567890",
tag.WorkflowNamespace("test-namespace"),
tag.WorkflowScheduledEventID(int64(i)), tag.ClusterName("this is a very long value: 1234567890 1234567890 1234567890 1234567890"))
}
}