2021_12
参加者
syumai
magicpro
bnn
Nobishii
読むもの
リンク集 https://zenn.dev/syumai/scraps/763efd267b3109
weekly proposal review meeting
https://github.com/golang/go/issues/33502#issuecomment-942579398
見るやつ
ここから https://github.com/golang/go/issues/33502#issuecomment-965821211
reflect.Value.Grow
https://github.com/golang/go/issues/48000#issuecomment-942569639
基本的なreflectのSetLenの使い方 https://play.golang.org/p/oxxWu0_JPxJ
reflect.Value.Bytes()
adressableな配列のValueからもBytes()を取りたい!
https://play.golang.org/p/YGuhIu6nVmT
ところで https://pkg.go.dev/testing#AllocsPerRun が便利そうだった
http.MaxBytesError
https://github.com/golang/go/issues/30715
https://github.com/golang/go/pull/49359
(*URL).PathJoin / url.JoinPath
https://github.com/golang/go/issues/47005#issuecomment-953167591
メモ
Go 1.18 Release Note https://tip.golang.org/doc/go1.18
リリパ https://gocon.connpass.com/event/234198/
code:golang
package main
import (
"reflect"
"testing"
)
func BenchmarkByAppend(b *testing.B) {
for i := 0; i < b.N; i++ {
s := make([]int, 0, 5)
v1 := reflect.ValueOf(&s).Elem()
v1 = reflect.Append(v1, reflect.ValueOf(1))
v1 = reflect.Append(v1, reflect.ValueOf(2))
}
}
func BenchmarkByAppend2(b *testing.B) {
for i := 0; i < b.N; i++ {
s := make([]int, 0, 5)
v1 := reflect.ValueOf(&s).Elem()
v1.Set(reflect.Append(v1, reflect.ValueOf(1)))
v1.Set(reflect.Append(v1, reflect.ValueOf(2)))
}
}
func BenchmarkBySet(b *testing.B) {
for i := 0; i < b.N; i++ {
s := make([]int, 0, 5)
v1 := reflect.ValueOf(&s).Elem()
v1.SetLen(2)
v1.Index(0).Set(reflect.ValueOf(1))
v1.Index(1).Set(reflect.ValueOf(2))
}
}
cpu: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
BenchmarkByAppend-16 6878270 172.4 ns/op 120 B/op 4 allocs/op
BenchmarkByAppend2-16 5854520 207.3 ns/op 120 B/op 4 allocs/op
BenchmarkBySet-16 12376485 97.96 ns/op 72 B/op 2 allocs/op
PASS