-
-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathbench_test.go
More file actions
32 lines (28 loc) · 838 Bytes
/
bench_test.go
File metadata and controls
32 lines (28 loc) · 838 Bytes
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
package compress
import (
"context"
"strings"
"testing"
"github.com/Siddhant-K-code/distill/pkg/types"
)
func BenchmarkCompress_ShortText(b *testing.B) {
c := NewExtractiveCompressor()
ctx := context.Background()
chunk := types.Chunk{ID: "bench", Text: "This is a short text for compression benchmarking."}
opts := DefaultOptions()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, _ = c.Compress(ctx, []types.Chunk{chunk}, opts)
}
}
func BenchmarkCompress_LongText(b *testing.B) {
c := NewExtractiveCompressor()
ctx := context.Background()
long := strings.Repeat("This is a longer text with more content for compression benchmarking. ", 50)
chunk := types.Chunk{ID: "bench", Text: long}
opts := DefaultOptions()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, _, _ = c.Compress(ctx, []types.Chunk{chunk}, opts)
}
}