Files
tasks/common/log/zap_logger_bench_test.go
Alex ShtinandGitHub 8e8f1b0f7c Remove license header from every file (#7689)
## What changed?
<!-- Describe what has changed in this PR -->
Remove license header from every file. Because it is really hard to
follow in this PR here is the summary:
1. License header is removed from all `.go` and `.proto` files
:fireworks::fireworks:🎆.
2. `LICENSE` file in the root directory has only Temporal and Uber
copyrights.
3. 5 other `LICENSE` files added to the packages which have copyrights
different from Temporal and Uber: Datadog, Xargin, "Mat Ryer, Tyler
Bunnell and contributors".
4. `license_file` flag is removed from all code generation tools.
5. `copyright_file` flag is removed from `go:generate mockgen`
directive.
6. All copyright related targets are removed from `Makefile`.
7. Updated Temporal copyright year to 2025 everywhere.

## Why?
<!-- Tell your future self why have you made these changes -->
I double checked with legal department that it is not needed to have
license header in every file. One file per repo is enough. I put all
copyrights to the root `LICENSE` file and removed header from all other
files. Also updated tools and `Makefile`.
2025-05-01 18:50:21 -07:00

71 lines
3.4 KiB
Go

package log
import (
"testing"
"go.temporal.io/server/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"))
}
}