Skip to content

Commit

Permalink
brain/braintest: test using think
Browse files Browse the repository at this point in the history
For #94.
  • Loading branch information
zephyrtronium committed Dec 22, 2024
1 parent 8f60f05 commit 7eeb676
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions brain/braintest/bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if _, _, err := brain.Speak(ctx, br, "bocchi", ""); err != nil {
b.Errorf("error while speaking: %v", err)
if _, _, err := brain.Think(ctx, br, "bocchi", ""); err != nil {
b.Errorf("error while thinking: %v", err)
}
}
})
Expand Down Expand Up @@ -174,8 +174,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if _, _, err := brain.Speak(ctx, br, "bocchi", ""); err != nil {
b.Errorf("error while speaking: %v", err)
if _, _, err := brain.Think(ctx, br, "bocchi", ""); err != nil {
b.Errorf("error while thinking: %v", err)
}
}
})
Expand Down Expand Up @@ -220,8 +220,8 @@ func BenchSpeak(ctx context.Context, b *testing.B, new func(ctx context.Context,
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
if _, _, err := brain.Speak(ctx, br, "bocchi", toks[rand.IntN(len(toks)-1)]); err != nil {
b.Errorf("error while speaking: %v", err)
if _, _, err := brain.Think(ctx, br, "bocchi", toks[rand.IntN(len(toks)-1)]); err != nil {
b.Errorf("error while thinking: %v", err)
}
}
})
Expand Down
10 changes: 5 additions & 5 deletions brain/braintest/braintest.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,9 @@ func speak(ctx context.Context, t *testing.T, br brain.Interface, tag, prompt st
t.Helper()
got := make(map[string]struct{}, 20)
for range iters {
s, trace, err := brain.Speak(ctx, br, tag, prompt)
s, trace, err := brain.Think(ctx, br, tag, prompt)
if err != nil {
t.Errorf("couldn't speak: %v", err)
t.Errorf("couldn't think: %v", err)
}
got[strings.Join(trace, " ")+"#"+s] = struct{}{}
}
Expand Down Expand Up @@ -257,11 +257,11 @@ func testCombinatoric(ctx context.Context, br brain.Interface) func(t *testing.T
}
}
allocs := testing.AllocsPerRun(10, func() {
_, _, err := brain.Speak(ctx, br, "bocchi", "")
_, _, err := brain.Think(ctx, br, "bocchi", "")
if err != nil {
t.Errorf("couldn't speak: %v", err)
t.Errorf("couldn't think: %v", err)
}
})
t.Logf("speaking cost %v allocs per run", allocs)
t.Logf("thinking cost %v allocs per run", allocs)
}
}
2 changes: 1 addition & 1 deletion brain/braintest/braintest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func (m *membrain) Think(ctx context.Context, tag string, prompt []string) iter.
// Check deletions during iteration so we don't unforget if the
// iterating loop forgets things.
m.mu.Lock()
ok := r.forgort[v[0]]
ok := m.tups[tag].forgort[v[0]]
m.mu.Unlock()
if ok {
continue
Expand Down

0 comments on commit 7eeb676

Please sign in to comment.