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

PERF: use buffer pool in json formatter #755

Merged
merged 1 commit into from
Jul 29, 2018
Merged

PERF: use buffer pool in json formatter #755

merged 1 commit into from
Jul 29, 2018

Conversation

taylorchu
Copy link
Contributor

benchmark             old ns/op     new ns/op     delta
BenchmarkLogrus-8     4163          4369          +4.95%

benchmark             old allocs     new allocs     delta
BenchmarkLogrus-8     36             31             -13.89%

benchmark             old bytes     new bytes     delta
BenchmarkLogrus-8     3027          2163          -28.54%
func BenchmarkLogrus(b *testing.B) {
	log := logrus.New()
	log.Formatter = &logrus.JSONFormatter{}
	log.Out = ioutil.Discard
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		log.
			WithField("foo1", "bar1").
			WithField("foo2", "bar2").
			Info("this is a dummy log")
	}
}

benchmark             old ns/op     new ns/op     delta
BenchmarkLogrus-8     4163          4369          +4.95%

benchmark             old allocs     new allocs     delta
BenchmarkLogrus-8     36             31             -13.89%

benchmark             old bytes     new bytes     delta
BenchmarkLogrus-8     3027          2163          -28.54%
@taylorchu
Copy link
Contributor Author

@sirupsen this idea is also in text_formatter. Could you take a look? thanks!

@sirupsen
Copy link
Owner

@stevvooe @seiffert do you mind taking a look at this?

@dgsb dgsb merged commit aa6766a into sirupsen:master Jul 29, 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

Successfully merging this pull request may close these issues.

None yet

3 participants