]> Cypherpunks.ru repositories - gostls13.git/blobdiff - src/reflect/benchmark_test.go
reflect: optimize Value.IsZero for array types
[gostls13.git] / src / reflect / benchmark_test.go
index b499ad71220326f3f8784e01721e73b01ed9d649..4aa47669a27507309792915fbe8d18f1202cf6ac 100644 (file)
@@ -120,12 +120,26 @@ func BenchmarkMapsDeepEqual(b *testing.B) {
 }
 
 func BenchmarkIsZero(b *testing.B) {
-       source := ValueOf(struct {
-               ArrayComparable    [4]T
-               ArrayIncomparable  [4]_Complex
-               StructComparable   T
-               StructIncomparable _Complex
-       }{})
+       type Int4 struct {
+               a, b, c, d int
+       }
+       type Int1024 struct {
+               a [1024]int
+       }
+       s := struct {
+               ArrayComparable      [4]T
+               ArrayIncomparable    [4]_Complex
+               StructComparable     T
+               StructIncomparable   _Complex
+               ArrayInt_4           [4]int
+               ArrayInt_1024        [1024]int
+               ArrayInt_1024_NoZero [1024]int
+               Struct4Int           Int4
+               ArrayStruct4Int_1024 [256]Int4
+               ArrayChanInt_1024    [1024]chan int
+       }{}
+       s.ArrayInt_1024_NoZero[512] = 1
+       source := ValueOf(s)
 
        for i := 0; i < source.NumField(); i++ {
                name := source.Type().Field(i).Name