Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Logger is slow in OFF level #23

Open
vicanso opened this issue Jun 28, 2018 · 0 comments
Open

Logger is slow in OFF level #23

vicanso opened this issue Jun 28, 2018 · 0 comments

Comments

@vicanso
Copy link

vicanso commented Jun 28, 2018

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
vicanso added a commit to vicanso/gommon that referenced this issue Jun 28, 2018
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

No branches or pull requests

1 participant