-
Notifications
You must be signed in to change notification settings - Fork 9
/
creation_test.go
77 lines (60 loc) · 1.66 KB
/
creation_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
package rquad
import (
"image"
"testing"
"github.com/arl/go-rquad/internal"
"github.com/arl/imgtools/imgscan"
)
func benchmarkQuadtreeCreation(b *testing.B, fn newQuadtreeFunc, resolution int) {
var (
bm image.Image
err error
scanner imgscan.Scanner
)
bm, err = internal.LoadPNG("./testdata/bigsquare.png")
checkB(b, err)
scanner, err = imgscan.NewScanner(bm)
checkB(b, err)
// run N times
b.ResetTimer()
for n := 0; n < b.N; n++ {
_, err := fn(scanner, resolution)
checkB(b, err)
}
}
func BenchmarkBasicCreationRes32(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 32)
}
func BenchmarkBasicCreationRes16(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 16)
}
func BenchmarkBasicCreationRes8(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 8)
}
func BenchmarkBasicCreationRes4(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 4)
}
func BenchmarkBasicCreationRes2(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 2)
}
func BenchmarkBasicCreationRes1(b *testing.B) {
benchmarkQuadtreeCreation(b, newBasicTree, 1)
}
func BenchmarkCNTreeCreationRes32(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 32)
}
func BenchmarkCNTreeCreationRes16(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 16)
}
func BenchmarkCNTreeCreationRes8(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 8)
}
func BenchmarkCNTreeCreationRes4(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 4)
}
func BenchmarkCNTreeCreationRes2(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 2)
}
func BenchmarkCNTreeCreationRes1(b *testing.B) {
benchmarkQuadtreeCreation(b, newCNTree, 1)
}