-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch_test.go
45 lines (39 loc) · 859 Bytes
/
search_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
package main
import (
"log"
"testing"
"github.com/hbollon/go-edlib"
"github.com/serverwentdown/datetime.link/data"
)
func TestEditDistance(t *testing.T) {
res, err := edlib.StringsSimilarity("Singapore", "Sing", edlib.JaroWinkler)
if err != nil {
return
}
log.Printf("%f", res)
}
func BenchmarkCompare(b *testing.B) {
for i := 0; i < b.N; i++ {
_, _ = compare("Random String That Is Quite Long", "Singapore")
}
}
func BenchmarkCompareCity(b *testing.B) {
cities, err := data.ReadCities()
if err != nil {
panic(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = compareCity(cities["Singapore-SG"], "Singapore")
}
}
func BenchmarkFullSearchCities(b *testing.B) {
cities, err := data.ReadCities()
if err != nil {
panic(err)
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _ = FullSearchCities(cities, "Singapore")
}
}