-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathutm_benchmark_test.go
executable file
·60 lines (48 loc) · 1.19 KB
/
utm_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
58
59
60
package UTM_test
import (
"testing"
"github.com/im7mortal/UTM"
)
func getBenchmarkCoordinate() testCoordinate {
return testCoordinate{466013, 7190568, 6, "W"}
}
func BenchmarkToLatLon(b *testing.B) {
var err error
coordinate := getBenchmarkCoordinate()
for i := 0; i < b.N; i++ {
if _, _, err = UTM.ToLatLon(
coordinate.Easting,
coordinate.Northing,
coordinate.ZoneNumber,
coordinate.ZoneLetter); err != nil {
b.Fatal("benchmark fatal BenchmarkToLatLon")
}
}
}
func BenchmarkToLatLonWithNorthern(b *testing.B) {
var err error
coordinate := getBenchmarkCoordinate()
coordinate.ZoneLetter = ""
for i := 0; i < b.N; i++ {
if _, _, err = UTM.ToLatLon(
coordinate.Easting,
coordinate.Northing,
coordinate.ZoneNumber,
coordinate.ZoneLetter,
true); err != nil {
b.Fatal("benchmark fatal BenchmarkToLatLonWithNorthern")
}
}
}
func getLatLon() testLatLon {
return testLatLon{64.83778, -147.71639}
}
func BenchmarkFromLatLon(b *testing.B) {
var err error
latLon := getLatLon()
for i := 0; i < b.N; i++ {
if _, _, _, _, err = UTM.FromLatLon(latLon.Latitude, latLon.Longitude, false); err != nil {
b.Fatal("benchmark fatal BenchmarkFromLatLon")
}
}
}