| 1 | package transcript |
| 2 | |
| 3 | import ( |
| 4 | "fmt" |
| 5 | "strings" |
| 6 | "testing" |
| 7 | ) |
| 8 | |
| 9 | func BenchmarkTranscriptCheckpointLargeHistory(b *testing.B) { |
| 10 | const count = 2048 |
| 11 | body := strings.Repeat("x", 16<<10) |
| 12 | rows := make([]Message, count) |
| 13 | for i := range rows { |
| 14 | rows[i] = Message{MessageID: fmt.Sprint(i), Role: "assistant", Content: body} |
| 15 | } |
| 16 | p, err := NewProjection(testIdentity, rows, 0) |
| 17 | if err != nil { |
| 18 | b.Fatal(err) |
| 19 | } |
| 20 | b.SetBytes(int64(count * len(body))) |
| 21 | b.ReportAllocs() |
| 22 | b.ResetTimer() |
| 23 | for b.Loop() { |
| 24 | state, err := p.Checkpoint("digest") |
| 25 | if err != nil || len(state.Records) != count { |
| 26 | b.Fatal("checkpoint failed", err) |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 |