-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathcitylots_bench_test.go
55 lines (45 loc) · 1.1 KB
/
citylots_bench_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
package quamina
import (
"testing"
)
func BenchmarkCityLots(b *testing.B) {
var localMatches []X
patterns := []string{
`{ "properties": { "STREET": [ "CRANLEIGH" ] } }`,
`{ "properties": { "STREET": [ "17TH" ], "ODD_EVEN": [ "E"] } }`,
`{ "geometry": { "coordinates": [ 37.807807921694092 ] } }`,
`{ "properties": { "MAPBLKLOT": ["0011008"], "BLKLOT": ["0011008"]}, "geometry": { "coordinates": [ 37.807807921694092 ] } } `,
}
names := []string{
"CRANLEIGH",
"17TH Even",
"Geometry",
"0011008",
}
var err error
q, err := New()
if err != nil {
b.Fatalf("New(): %s", err.Error())
}
for i := range names {
err = q.AddPattern(names[i], patterns[i])
if err != nil {
b.Fatalf("AddPattern failed: %s", err.Error())
}
}
b.Log(matcherStats(q.matcher.(*coreMatcher)))
lines := getCityLotsLines(b)
b.ResetTimer()
for i := 0; i < b.N; i++ {
lineIndex := i
if i >= len(lines) {
lineIndex = 0
}
matches, err := q.MatchesForEvent(lines[lineIndex])
if err != nil {
b.Errorf("Matches4JSON: %s", err.Error())
}
localMatches = matches
}
topMatches = localMatches
}