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

[WIP] Add benchmark, reuse nodes #48

Closed

Conversation

lestrrat
Copy link
Contributor

まずベースラインのベンチマークを取ってみたところ以下のように結構差がありました

    Benchmark/gopkg.in/yaml.v2-4               65980             23857 ns/op            9305 B/op         97 allocs/op
    Benchmark/gopkg.in/yaml.v3-4               67689             18478 ns/op            9305 B/op         97 allocs/op
    Benchmark/github.com/goccy/go-yaml-4       53563             22335 ns/op           17816 B/op        297 allocs/op
    PASS
    ok      github.com/goccy/go-yaml        4.633s

とりあえずallocationを減らすのはちょっといけそうかな?と思ったのでやってみたけど、以下の結果を見る限りスピードにはあまり紐付いてない感じですね。メモリは使わなくなったけど…

    Benchmark/gopkg.in/yaml.v2-4               57750             18393 ns/op            9305 B/op         97 allocs/op
    Benchmark/gopkg.in/yaml.v3-4               61083             18025 ns/op            9305 B/op         97 allocs/op
    Benchmark/github.com/goccy/go-yaml-4       43956             22944 ns/op           16729 B/op        279 allocs/op
    PASS
    ok      github.com/goccy/go-yaml        3.876s

Tokenまわりももう少しallocationは減らせる(Token{} をreuseして、Tokens{} を使い終わったらリリース)と思ってますけど、とりあえず疲れたので一旦ここまで。少なくともWIPが取れるまでは真面目にレビューしてもらう必要はありません。

baseline:

% go test -v -run=Benchmark -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/goccy/go-yaml
Benchmark/gopkg.in/yaml.v2-4         	  111703	     11104 ns/op	    7648 B/op	      62 allocs/op
Benchmark/gopkg.in/yaml.v3-4         	  102380	     10872 ns/op	    7648 B/op	      62 allocs/op
Benchmark/github.com/goccy/go-yaml-4 	   93008	     13411 ns/op	   10392 B/op	     170 allocs/op
PASS
ok  	github.com/goccy/go-yaml	4.920s
finch% go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/goccy/go-yaml
Benchmark/gopkg.in/yaml.v2-4         	   65980	     23857 ns/op	    9305 B/op	      97 allocs/op
Benchmark/gopkg.in/yaml.v3-4         	   67689	     18478 ns/op	    9305 B/op	      97 allocs/op
Benchmark/github.com/goccy/go-yaml-4 	   53563	     22335 ns/op	   17816 B/op	     297 allocs/op
PASS
ok  	github.com/goccy/go-yaml	4.633s
finch% go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/goccy/go-yaml
Benchmark/gopkg.in/yaml.v2-4         	   67729	     19035 ns/op	    9305 B/op	      97 allocs/op
Benchmark/gopkg.in/yaml.v3-4         	   69040	     17593 ns/op	    9305 B/op	      97 allocs/op
Benchmark/github.com/goccy/go-yaml-4 	   49203	     24517 ns/op	   16746 B/op	     280 allocs/op
PASS
ok  	github.com/goccy/go-yaml	6.368s
finch% go test -bench . -benchmem
goos: darwin
goarch: amd64
pkg: github.com/goccy/go-yaml
Benchmark/gopkg.in/yaml.v2-4         	   57750	     18393 ns/op	    9305 B/op	      97 allocs/op
Benchmark/gopkg.in/yaml.v3-4         	   61083	     18025 ns/op	    9305 B/op	      97 allocs/op
Benchmark/github.com/goccy/go-yaml-4 	   43956	     22944 ns/op	   16729 B/op	     279 allocs/op
PASS
ok  	github.com/goccy/go-yaml	3.876s
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

2 participants