-
Notifications
You must be signed in to change notification settings - Fork 46
/
benchmark_test.go
57 lines (50 loc) · 1.18 KB
/
benchmark_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// +build go1.7
package geohash
import (
"strconv"
"testing"
)
func BenchmarkEncodeInt(b *testing.B) {
points := RandomPoints(1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
EncodeInt(points[i%1024][0], points[i%1024][1])
}
}
func BenchmarkEncode(b *testing.B) {
points := RandomPoints(1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
Encode(points[i%1024][0], points[i%1024][1])
}
}
func BenchmarkEncodeWithPrecision(b *testing.B) {
points := RandomPoints(1024)
for chars := uint(1); chars <= 12; chars++ {
name := strconv.FormatUint(uint64(chars), 10)
b.Run(name, func(b *testing.B) {
for i := 0; i < b.N; i++ {
EncodeWithPrecision(points[i%1024][0], points[i%1024][1], chars)
}
})
}
}
func BenchmarkDecodeInt(b *testing.B) {
geohashes := RandomIntGeohashes(1024)
b.ResetTimer()
for i := 0; i < b.N; i++ {
DecodeInt(geohashes[i%1024])
}
}
func BenchmarkDecode(b *testing.B) {
for chars := uint(1); chars <= 12; chars++ {
name := strconv.FormatUint(uint64(chars), 10)
b.Run(name, func(b *testing.B) {
geohashes := RandomStringGeohashesWithPrecision(1024, chars)
b.ResetTimer()
for i := 0; i < b.N; i++ {
Decode(geohashes[i%1024])
}
})
}
}