/
autocomplete_bench_test.go
49 lines (38 loc) · 1.09 KB
/
autocomplete_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
// Copyright 2016 David Lavieri. All rights reserved.
// Use of this source code is governed by a MIT License
// License that can be found in the LICENSE file.
package goradix
import "testing"
// ----------------------- Benchmarks ------------------------ //
func BenchmarkAutocompleteStringLeftWords(b *testing.B) {
rx := New(false)
insertData(rx, sampleData2)
sd2 := sampleData2()
for i := 0; i < b.N; i++ {
rx.AutoComplete(randomString(sd2), false)
}
}
func BenchmarkAutocompleteStringFullWords(b *testing.B) {
rx := New(false)
insertData(rx, sampleData2)
sd2 := sampleData2()
for i := 0; i < b.N; i++ {
rx.AutoComplete(randomString(sd2), true)
}
}
func BenchmarkAutocompleteBytesLeftWords(b *testing.B) {
rx := New(false)
insertDataBytes(rx, sampleData2Bytes)
sd3 := sampleData2Bytes()
for i := 0; i < b.N; i++ {
rx.AutoCompleteBytes(randomBytes(sd3), false)
}
}
func BenchmarkAutocompleteBytesFullWords(b *testing.B) {
rx := New(false)
insertDataBytes(rx, sampleData2Bytes)
sd3 := sampleData2Bytes()
for i := 0; i < b.N; i++ {
rx.AutoCompleteBytes(randomBytes(sd3), true)
}
}