This repository has been archived by the owner on Jun 28, 2021. It is now read-only.
forked from paulmach/go.geo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmarks_wkb_test.go
95 lines (78 loc) · 2.06 KB
/
benchmarks_wkb_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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package geo
import "testing"
func BenchmarkPointScan(b *testing.B) {
p := NewPoint(0, 0)
data := []uint8{1, 1, 0, 0, 0, 15, 152, 60, 227, 24, 157, 94, 192, 205, 11, 17, 39, 128, 222, 66, 64}
err := p.Scan(data)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p.Scan(data)
}
}
func BenchmarkPointUnmarshalWKB(b *testing.B) {
p := NewPoint(0, 0)
data := []uint8{1, 1, 0, 0, 0, 15, 152, 60, 227, 24, 157, 94, 192, 205, 11, 17, 39, 128, 222, 66, 64}
err := p.unmarshalWKB(data)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p.unmarshalWKB(data)
}
}
func BenchmarkLineScan(b *testing.B) {
l := &Line{}
data := []byte{1, 2, 0, 0, 0, 2, 0, 0, 0, 213, 7, 146, 119, 14, 193, 94, 192, 93, 250, 151, 164, 50, 5, 67, 64, 26, 164, 224, 41, 228, 170, 94, 192, 22, 75, 145, 124, 37, 70, 67, 64}
err := l.Scan(data)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.Scan(data)
}
}
func BenchmarkLineUnmarshalWKB(b *testing.B) {
l := &Line{}
data := []byte{1, 2, 0, 0, 0, 2, 0, 0, 0, 213, 7, 146, 119, 14, 193, 94, 192, 93, 250, 151, 164, 50, 5, 67, 64, 26, 164, 224, 41, 228, 170, 94, 192, 22, 75, 145, 124, 37, 70, 67, 64}
err := l.unmarshalWKB(data)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
l.unmarshalWKB(data)
}
}
func BenchmarkPathScan(b *testing.B) {
p := NewPath()
err := p.Scan(testPathWKB)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p.Scan(testPathWKB)
}
}
func BenchmarkPathUnmarshalWKB(b *testing.B) {
p := NewPath()
err := p.unmarshalWKB(testPathWKB)
if err != nil {
b.Fatalf("should scan without error, got %v", err)
}
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
p.unmarshalWKB(testPathWKB)
}
}