Skip to content

Logger is slow in OFF level #23

Open
@vicanso

Description

@vicanso

I set the log's level to OFF and I thought that log function should be fast. However it seemed to be slower than of noop function. I have tested like this:

func BenchmarkEchoLog(b *testing.B) {
	e := echo.New()
	e.Logger.SetLevel(log.Lvl(log.OFF))
	c := e.NewContext(nil, nil)
	for i := 0; i < b.N; i++ {
		c.Logger().Debug("a")
	}
}

func BenchmarkNoop(b *testing.B) {
	noop := func(args ...interface{}) {}
	for i := 0; i < b.N; i++ {
		noop("a")
	}
}
BenchmarkEchoLog-4                  	 1000000	      1778 ns/op
BenchmarkNoop-4                     	30000000	        40.8 ns/op

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions