Skip to content

Commit 6188549

Browse files
authored
Merge pull request golang#114 from jmr/latlng-bm
latlng_test: Add benchmark functions
2 parents 2fc3d43 + c5e5a69 commit 6188549

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

s2/latlng_test.go

Lines changed: 16 additions & 0 deletions
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)