benchmark old ns/op new ns/op delta
BenchmarkMapsDeepEqual-10 235 200 -15.05%
benchmark old allocs new allocs delta
BenchmarkMapsDeepEqual-10 7 6 -14.29%
benchmark old bytes new bytes delta
BenchmarkMapsDeepEqual-10 96 48 -50.00%
Change-Id: Ifa625ad25524cc9ee438711917606626b33a9597
Reviewed-on: https://go-review.googlesource.com/c/go/+/512576
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
}
}
+func BenchmarkMapsDeepEqual(b *testing.B) {
+ m1 := map[int]int{
+ 1: 1, 2: 2,
+ }
+ m2 := map[int]int{
+ 1: 1, 2: 2,
+ }
+ for i := 0; i < b.N; i++ {
+ DeepEqual(m1, m2)
+ }
+}
+
func BenchmarkIsZero(b *testing.B) {
source := ValueOf(struct {
ArrayComparable [4]T
if v1.UnsafePointer() == v2.UnsafePointer() {
return true
}
- for _, k := range v1.MapKeys() {
- val1 := v1.MapIndex(k)
- val2 := v2.MapIndex(k)
+ iter := v1.MapRange()
+ for iter.Next() {
+ val1 := iter.Value()
+ val2 := v2.MapIndex(iter.Key())
if !val1.IsValid() || !val2.IsValid() || !deepValueEqual(val1, val2, visited) {
return false
}