|
9 | 9 | "strconv"
|
10 | 10 | "strings"
|
11 | 11 | "testing"
|
12 |
| - "time" |
13 | 12 |
|
14 | 13 | "github.com/zephyrtronium/robot/brain"
|
15 | 14 | "github.com/zephyrtronium/robot/userhash"
|
@@ -45,7 +44,8 @@ func BenchLearn(ctx context.Context, b *testing.B, new func(ctx context.Context,
|
45 | 44 | toks[len(toks)-1] = strconv.FormatInt(t, 10)
|
46 | 45 | id := randid()
|
47 | 46 | u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{}))))
|
48 |
| - err := brain.Learn(ctx, l, "bocchi", id, u, time.Unix(t, 0), strings.Join(toks, " ")) |
| 47 | + msg := brain.Message{ID: id, Sender: u, Timestamp: t * 1e3, Text: strings.Join(toks, " ")} |
| 48 | + err := brain.Learn(ctx, l, "bocchi", &msg) |
49 | 49 | if err != nil {
|
50 | 50 | b.Errorf("error while learning: %v", err)
|
51 | 51 | }
|
@@ -83,7 +83,8 @@ func BenchLearn(ctx context.Context, b *testing.B, new func(ctx context.Context,
|
83 | 83 | rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] })
|
84 | 84 | id := randid()
|
85 | 85 | u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{}))))
|
86 |
| - err := brain.Learn(ctx, l, "bocchi", id, u, time.Unix(t, 0), strings.Join(toks[:8], " ")) |
| 86 | + msg := brain.Message{ID: id, Sender: u, Timestamp: t * 1e3, Text: strings.Join(toks, " ")} |
| 87 | + err := brain.Learn(ctx, l, "bocchi", &msg) |
87 | 88 | if err != nil {
|
88 | 89 | b.Errorf("error while learning: %v", err)
|
89 | 90 | }
|
@@ -117,7 +118,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
|
117 | 118 | toks[len(toks)-1] = strconv.FormatInt(t, 10)
|
118 | 119 | id := randid()
|
119 | 120 | u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{}))))
|
120 |
| - err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), strings.Join(toks, " ")) |
| 121 | + msg := brain.Message{ID: id, Sender: u, Timestamp: t * 1e3, Text: strings.Join(toks, " ")} |
| 122 | + err := brain.Learn(ctx, br, "bocchi", &msg) |
121 | 123 | if err != nil {
|
122 | 124 | b.Errorf("error while learning: %v", err)
|
123 | 125 | }
|
@@ -162,7 +164,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
|
162 | 164 | rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] })
|
163 | 165 | id := randid()
|
164 | 166 | u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{}))))
|
165 |
| - err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), strings.Join(toks, " ")) |
| 167 | + msg := brain.Message{ID: id, Sender: u, Timestamp: t * 1e3, Text: strings.Join(toks, " ")} |
| 168 | + err := brain.Learn(ctx, br, "bocchi", &msg) |
166 | 169 | if err != nil {
|
167 | 170 | b.Errorf("error while learning: %v", err)
|
168 | 171 | }
|
@@ -207,7 +210,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
|
207 | 210 | rand.Shuffle(len(toks), func(i, j int) { toks[i], toks[j] = toks[j], toks[i] })
|
208 | 211 | id := randid()
|
209 | 212 | u := userhash.Hash(randbytes(make([]byte, len(userhash.Hash{}))))
|
210 |
| - err := brain.Learn(ctx, br, "bocchi", id, u, time.Unix(t, 0), strings.Join(toks, " ")) |
| 213 | + msg := brain.Message{ID: id, Sender: u, Timestamp: t * 1e3, Text: strings.Join(toks, " ")} |
| 214 | + err := brain.Learn(ctx, br, "bocchi", &msg) |
211 | 215 | if err != nil {
|
212 | 216 | b.Errorf("error while learning: %v", err)
|
213 | 217 | }
|
|
0 commit comments