Skip to content

Refactored Position of Regexp#1

Open
MakoTano wants to merge 1 commit intotakeshy:masterfrom
MakoTano:refactor_position_of_regexp
Open

Refactored Position of Regexp#1
MakoTano wants to merge 1 commit intotakeshy:masterfrom
MakoTano:refactor_position_of_regexp

Conversation

@MakoTano
Copy link
Copy Markdown

@MakoTano MakoTano commented Nov 29, 2017

I made regexps as package valuables for decreasing memory allocation counts.

benchmark code (logmon_test.go, same folder w/ logmon.go)

package main

import (
	"testing"
)

func Benchmark_parseConf(b *testing.B) {
	for i := 0; i < b.N; i++ {
			parseConf(`:/var/log/system.log\n(ERROR)\necho -e 'ERROR\n<%%%%>\n'`)
	}
}

before

$ go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/MakoTano/logmon-go
Benchmark_parseConf-4   	   50000	     27605 ns/op	   55184 B/op	     198 allocs/op
PASS
ok  	github.com/MakoTano/logmon-go	1.683s

this PR

$ go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/MakoTano/logmon-go
Benchmark_parseConf-4   	  500000	      2888 ns/op	     192 B/op	       5 allocs/op
PASS
ok  	github.com/MakoTano/logmon-go	1.482s

thank you for nice OSS, I've using this in our production. I love it.

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.

1 participant