Skip to content

Commit c5e5a69

Browse files
committed
latlng_test: Add benchmark functions
1 parent bd601d2 commit c5e5a69

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

s2/latlng_test.go

+16
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,19 @@ func TestLatLngApproxEqual(t *testing.T) {
168168
}
169169
}
170170
}
171+
172+
func BenchmarkPointFromLatLng(b *testing.B) {
173+
ll := LatLng{s1.E7 * 0x150bc888, s1.E7 * 0x5099d63f}
174+
for i := 0; i < b.N; i++ {
175+
PointFromLatLng(ll)
176+
}
177+
}
178+
179+
func BenchmarkLatLngGetDistance(b *testing.B) {
180+
var sum s1.Angle
181+
x := LatLngFromDegrees(25.0, -78.0)
182+
for i := 0; i < b.N; i++ {
183+
y := LatLng{s1.E7 * s1.Angle(i), 56.0 * s1.Degree}
184+
sum += x.Distance(y)
185+
}
186+
}

0 commit comments

Comments
 (0)