-
Notifications
You must be signed in to change notification settings - Fork 9
/
kmp_bench_test.go
48 lines (39 loc) · 1.19 KB
/
kmp_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
package matrixprofile
import (
"testing"
"github.com/matrix-profile-foundation/go-matrixprofile/siggen"
)
func setupKData() [][]float64 {
sin := siggen.Sin(1, 4, 0, 0, 100, 0.25)
saw := siggen.Sawtooth(1, 4, 0, 0, 100, 0.25)
square := siggen.Square(1, 4, 0, 0, 100, 0.25)
line := siggen.Line(0, 0, len(sin)*4)
line2 := siggen.Line(0, 0, len(sin)*3)
sig := make([][]float64, 3)
sig[0] = siggen.Append(line, line, line, saw, line2, saw, line2)
sig[1] = siggen.Append(line, sin, line2, sin, line2, sin, line2, sin, line2)
sig[2] = siggen.Append(line, square, line2, square, line2, square, line2, square, line2)
noise := siggen.Noise(0.1, len(sig[0]))
sig[0] = siggen.Add(sig[0], noise)
noise = siggen.Noise(0.1, len(sig[0]))
sig[1] = siggen.Add(sig[1], noise)
noise = siggen.Noise(0.1, len(sig[0]))
sig[2] = siggen.Add(sig[2], noise)
return sig
}
func BenchmarkMStomp(b *testing.B) {
sig := setupKData()
mp, err := NewKMP(sig, 25)
if err != nil {
b.Error(err)
}
for i := 0; i < b.N; i++ {
err = mp.Compute()
if err != nil {
b.Error(err)
}
if len(mp.MP) < 1 || len(mp.Idx) < 1 {
b.Error("expected at least one dimension from matrix profile and matrix profile index")
}
}
}