Skip to content

Commit

Permalink
update workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
phuslu committed Apr 24, 2024
1 parent 6587795 commit b31417f
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 73 deletions.
26 changes: 22 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,28 @@ on:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
go_version: ['1.22', '1.21', '1.20', '1.19', '1.18']
steps:
- uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go_version }}
check-latest: true
- uses: actions/checkout@v4
- name: Build
run: go build -v -race
- name: Test
run: go test -v
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
go-version: '1.22'
check-latest: true
- uses: actions/checkout@v4
- name: Lint
run: |
git clone --depth=1 https://github.com/${GITHUB_REPOSITORY}
cd $(basename ${GITHUB_REPOSITORY})
go build -v -race
go test -v
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v1.57.2
./bin/golangci-lint run
21 changes: 0 additions & 21 deletions .github/workflows/lint.yml

This file was deleted.

97 changes: 49 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -839,21 +839,6 @@ func BenchmarkDisableZap(b *testing.B) {
}
}

func BenchmarkDisableZeroLog(b *testing.B) {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
for i := 0; i < b.N; i++ {
logger.Debug().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkDisablePhusLog(b *testing.B) {
logger := log.Logger{Level: log.InfoLevel, Writer: log.IOWriter{io.Discard}}
for i := 0; i < b.N; i++ {
logger.Debug().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkNormalZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
Expand All @@ -865,54 +850,59 @@ func BenchmarkNormalZap(b *testing.B) {
}
}

func BenchmarkNormalZeroLog(b *testing.B) {
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
func BenchmarkPrintfZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(io.Discard),
zapcore.InfoLevel,
)).Sugar()
for i := 0; i < b.N; i++ {
logger.Info().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
logger.Infof("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
}
}

func BenchmarkNormalPhusLog(b *testing.B) {
logger := log.Logger{Writer: log.IOWriter{io.Discard}}
func BenchmarkCallerZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(io.Discard),
zapcore.InfoLevel),
zap.AddCaller(),
)
for i := 0; i < b.N; i++ {
logger.Info().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
logger.Info(msg, zap.String("rate", "15"), zap.Int("low", 16), zap.Float32("high", 123.2))
}
}

func BenchmarkPrintfZap(b *testing.B) {
func BenchmarkInterfaceZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(io.Discard),
zapcore.InfoLevel,
)).Sugar()
for i := 0; i < b.N; i++ {
logger.Infof("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
logger.Infow(msg, "object", &obj)
}
}

func BenchmarkPrintfZeroLog(b *testing.B) {
func BenchmarkDisableZeroLog(b *testing.B) {
zerolog.SetGlobalLevel(zerolog.InfoLevel)
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
for i := 0; i < b.N; i++ {
logger.Info().Msgf("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
logger.Debug().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkPrintfPhusLog(b *testing.B) {
logger := log.Logger{Writer: log.IOWriter{io.Discard}}
func BenchmarkNormalZeroLog(b *testing.B) {
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
for i := 0; i < b.N; i++ {
logger.Info().Msgf("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
logger.Info().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkCallerZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(io.Discard),
zapcore.InfoLevel),
zap.AddCaller(),
)
func BenchmarkPrintfZeroLog(b *testing.B) {
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
for i := 0; i < b.N; i++ {
logger.Info(msg, zap.String("rate", "15"), zap.Int("low", 16), zap.Float32("high", 123.2))
logger.Info().Msgf("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
}
}

Expand All @@ -923,28 +913,39 @@ func BenchmarkCallerZeroLog(b *testing.B) {
}
}

func BenchmarkCallerPhusLog(b *testing.B) {
logger := log.Logger{Caller: 1, Writer: log.IOWriter{io.Discard}}
func BenchmarkInterfaceZeroLog(b *testing.B) {
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
for i := 0; i < b.N; i++ {
logger.Info().Interface("object", &obj).Msg(msg)
}
}


func BenchmarkDisablePhusLog(b *testing.B) {
logger := log.Logger{Level: log.InfoLevel, Writer: log.IOWriter{io.Discard}}
for i := 0; i < b.N; i++ {
logger.Debug().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkNormalPhusLog(b *testing.B) {
logger := log.Logger{Writer: log.IOWriter{io.Discard}}
for i := 0; i < b.N; i++ {
logger.Info().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

func BenchmarkInterfaceZap(b *testing.B) {
logger := zap.New(zapcore.NewCore(
zapcore.NewJSONEncoder(zap.NewProductionEncoderConfig()),
zapcore.AddSync(io.Discard),
zapcore.InfoLevel,
)).Sugar()
func BenchmarkPrintfPhusLog(b *testing.B) {
logger := log.Logger{Writer: log.IOWriter{io.Discard}}
for i := 0; i < b.N; i++ {
logger.Infow(msg, "object", &obj)
logger.Info().Msgf("rate=%s low=%d high=%f msg=%s", "15", 16, 123.2, msg)
}
}

func BenchmarkInterfaceZeroLog(b *testing.B) {
logger := zerolog.New(io.Discard).With().Timestamp().Logger()
func BenchmarkCallerPhusLog(b *testing.B) {
logger := log.Logger{Caller: 1, Writer: log.IOWriter{io.Discard}}
for i := 0; i < b.N; i++ {
logger.Info().Interface("object", &obj).Msg(msg)
logger.Info().Str("rate", "15").Int("low", 16).Float32("high", 123.2).Msg(msg)
}
}

Expand Down

0 comments on commit b31417f

Please sign in to comment.